How to get the hour, minutes and seconds

11,379

Solution 1

The answer is

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

Solution 2

Hours_=now.time_duration().hours;
...
Share:
11,379

Related videos on Youtube

Caesar
Author by

Caesar

C++ developer.

Updated on September 16, 2022

Comments

  • Caesar
    Caesar over 1 year
    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.

  • Andrew Hundt
    Andrew Hundt over 9 years
    Can you add a link to the source in the documentation so I know where to find it in the future?