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.
How do I convert 1 hour in seconds? Multiply the hours by 60 to convert it to minutes, i.e., 1 hr × 60 = 60 minutes . Multiply the minutes by 60 to obtain the number of seconds, i.e., 60 minutes × 60 = 3600 seconds .
There are 60 minutes in 1 hour. To convert from minutes to hours, divide the number of minutes by 60. For example, 120 minutes equals 2 hours because 120/60=2.
Another simple technique to calculate the duration between two times in Excel is using the TEXT function: Calculate hours between two times: =TEXT(B2-A2, "h") Return hours and minutes between 2 times: =TEXT(B2-A2, "h:mm") Return hours, minutes and seconds between 2 times: =TEXT(B2-A2, "h:mm:ss")
2.47 hours is 2 hours, 28 minutes and 12 seconds. 2.47 hours is also equivalent to 148 minutes and 12 seconds or 8892 seconds.
The answer is
now.time_of_day().hours();
now.time_of_day().minutes();
now.time_of_day().seconds();
Hours_=now.time_duration().hours;
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With