当地时间用毫秒 [英] Local time with milliseconds
本文介绍了当地时间用毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何能得到当前的时间与库提振。我可以这样做:
how can I get current time with library boost. I can do this:
ptime now = boost::posix_timesecond_clock::local_time();
tm d_tm = to_tm(now);
但 TM 结构的最后一个时间单位为秒,我需要在毫秒。我能得到当前的时间毫秒?
But the last time unit of tm structure is second and I need in millisecond. Can I get current time with milliseconds?
推荐答案
看<一个href=\"http://www.boost.org/doc/libs/1_43_0/doc/html/date_time/posix_time.html\">boost::posix_time::microsec_clock::local_time()
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <iostream>
int
main()
{
boost::posix_time::ptime time = boost::posix_time::microsec_clock::local_time();
boost::posix_time::time_duration duration( time.time_of_day() );
std::cout << duration.total_milliseconds() << std::endl;
return 0;
}
这篇关于当地时间用毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文