2012-10-05 83 views
7
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的年,月和日,但我無法弄清楚如何獲得小時,分鐘和秒。你能幫我解決嗎?如何獲得小時,分鐘和秒

回答

13

答案是

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

你能文檔所以在添加一個鏈接到源我知道在哪裏可以找到它的未來? –

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