本文介绍了如何获取时间在millis在c + +就像java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,您可以这样做:

In Java you can do this:

long now = (new Date()).getTime();

如何在c ++中做同样的事?

How can I do the same but in c++ ?

推荐答案

在标准C ++中没有这样的方法(在标准C ++中,只有第二精度,而不是毫秒)。你可以在非便携式的方式,但由于你没有指定,我会假设你想要一个便携式的解决方案。您最好的赌注,我会说,是增强功能。

There is no such method in standard C++ (in standard C++, there is only second-accuracy, not millisecond). You can do it in non-portable ways, but since you didn't specify I will assume that you want a portable solution. Your best bet, I would say, is the boost function microsec_clock::local_time().

这篇关于如何获取时间在millis在c + +就像java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 10:42