Skip to content

Instantly share code, notes, and snippets.

@juniorcesarabreu
Created April 12, 2017 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniorcesarabreu/3800502afd96707ebffc337cab8d9185 to your computer and use it in GitHub Desktop.
Save juniorcesarabreu/3800502afd96707ebffc337cab8d9185 to your computer and use it in GitHub Desktop.
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