如何获得小时,分钟和秒

时间:2012-10-05 23:00:31

标签: c++ boost boost-date-time

const boost::posix_time::ptime now= boost::posix_time::second_clock::local_time();

year_ = now.date().year();
month_ = now.date().month();
day_ = now.date().day();

这就是我如何获得boost :: posix_time :: ptime的年,月和日,但我无法弄清楚如何获得小时,分钟和秒。你能帮帮我吗?

2 个答案:

答案 0 :(得分:13)

答案是

now.time_of_day().hours(); 
now.time_of_day().minutes();
now.time_of_day().seconds();

答案 1 :(得分:1)

Hours_=now.time_duration().hours;
...