How to get date and time in C++

In C++11 and later versions, date and time is supported in the standard library through the chrono header file. To print out the date and time, you may still have to fall back on the std::time_t and std::tm structures and std::ctime and std::localtime functions from the ctime header file and std::put_time from iomanip header file.

The code sample below shows these in action:

Tried with: Visual C++ 2013

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s