Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get current timestamp in milliseconds since 1970
#include <chrono>
// http://stackoverflow.com/questions/19555121/how-to-get-current-timestamp-in-milliseconds-since-1970-just-the-way-java-gets
// If you have access to the C++ 11 libraries, check out the std::chrono library.
// You can use it to get the milliseconds since the Unix Epoch like this:
using namespace std::chrono;
milliseconds ms = duration_cast< milliseconds >(
system_clock::now().time_since_epoch()
);
printf("\n\ntimestamp: %ld\n\n", ms);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment