【发布时间】:2013-11-02 12:32:05
【问题描述】:
在 Java 中,我们可以使用 System.currentTimeMillis() 来获取当前时间戳(以毫秒为单位),即自纪元时间以来的 -
当前时间和当前时间之间的差异,以毫秒为单位 UTC 时间 1970 年 1 月 1 日午夜。
在 C++ 中如何得到相同的东西?
目前我正在使用它来获取当前时间戳 -
struct timeval tp;
gettimeofday(&tp, NULL);
long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000; //get current timestamp in milliseconds
cout << ms << endl;
这看起来对吗?
【问题讨论】: