我怎样才能通过图书馆提升获得当前时间。我可以做这个:
ptime now = boost::posix_timesecond_clock::local_time();
tm d_tm = to_tm(now);
但最后一个时间单位tm结构是第二位,我需要以毫秒为单位。我可以获取当前时间(以毫秒为单位)吗?
look at boost::posix_time::microsec_clock::local_time() http://www.boost.org/doc/libs/1_43_0/doc/html/date_time/posix_time.html
#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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)