9
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();

This is how I get the years, months and day out of boost::posix_time::ptime, but I can't figure out how to get the hour, minutes and seconds. Can you please help me out.

Caesar
  • 9,483
  • 8
  • 40
  • 66

2 Answers2

15

The answer is

now.time_of_day().hours(); 
now.time_of_day().minutes();
now.time_of_day().seconds();
xgdgsc
  • 1,367
  • 13
  • 38
Caesar
  • 9,483
  • 8
  • 40
  • 66
1
Hours_=now.time_duration().hours;
...
Christian Stieber
  • 9,954
  • 24
  • 23