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


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.