如何获得小时,分钟和秒

Cae*_*sar 8 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();
Run Code Online (Sandbox Code Playgroud)

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

Cae*_*sar 14

答案是

now.time_of_day().hours(); 
now.time_of_day().minutes();
now.time_of_day().seconds();
Run Code Online (Sandbox Code Playgroud)

  • 您可以在文档中添加指向源代码的链接,以便我知道将来在哪里可以找到它吗? (4认同)