Skip to content

Instantly share code, notes, and snippets.

@ksophocleous
Created September 8, 2014 12:20
Show Gist options
  • Save ksophocleous/f9c2eb8f13e188634fa8 to your computer and use it in GitHub Desktop.
Save ksophocleous/f9c2eb8f13e188634fa8 to your computer and use it in GitHub Desktop.
cross platform unix timestamp in c++
#include <iostream>
#include <chrono>
int main(int argc, char *argv[])
{
auto tp = std::chrono::system_clock::now();
auto dur = tp.time_since_epoch();
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(dur).count();
std::cout << "Timestamp: " << seconds << std::endl;
}
@martinkbrown
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment