I want to have the number of milliseconds since epoch. A popular solution looks like follows (one of the solutions of this question asked here Get time since epoch in milliseconds, preferably using C++11 chrono )
#include <iostream>
#include <chrono>
int main() {
auto millitime = std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::system_clock::now().time_since_epoch()).count();
std::cout << millitime << std::endl;
return 0;
}
compiling this with a call to g++
like g++ -std=c++11 main.cpp -o timetest
results in the output
1372686001
which is equal to the number of seconds since epoch!
Is this a bug in the glibc? in g++? my mistake?
g++ (Debian 4.7.3-4) 4.7.3
ldd (Debian EGLIBC 2.17-6) 2.17
Update: it works when using the g++ 4.8. So it is a gcc bug?!
g++-4.8 (Debian 4.8.1-2) 4.8.1