Created
July 12, 2014 13:46
-
-
Save ssendeavour/de9ecb9f8031b03ad11b to your computer and use it in GitHub Desktop.
print current date and time in Windows Visual Studio 2013 with C++11 chrono
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iomanip> | |
#include <ctime> | |
void PrintLocalTime() | |
{ | |
std::tm tmNow; | |
std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); | |
time_t t = std::chrono::system_clock::to_time_t(now); | |
localtime_s(&tmNow, &t); | |
std::cout << std::put_time(&tmNow, "Date: %x\nTime: %X\n") << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment