Created
April 12, 2017 13:42
-
-
Save juniorcesarabreu/3800502afd96707ebffc337cab8d9185 to your computer and use it in GitHub Desktop.
How to get current timestamp in milliseconds since 1970
This file contains 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> | |
// 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