Skip to content

Instantly share code, notes, and snippets.

@ssendeavour
Created July 12, 2014 13:46
Show Gist options
  • Save ssendeavour/de9ecb9f8031b03ad11b to your computer and use it in GitHub Desktop.
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
#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