Page 1 of 1

Convert Hour from 12 Hr to 24 Hr syntax.

PostPosted: Sun Jul 14, 2019 10:01 pm
by Stewart
I'm using time.h with tm_hour to get the hour of the day, but the time is in 12 Hr format by default.
I would like to use 24 Hour format (00-23 Hrs).

What is the simplest method to format a tm_hours (12Hr) value to %H hours?
I can not find an example. My code snippet is below.

Code: Select alltime_t now;
      struct tm * timeinfo;
      timeinfo = localtime(&now);
        if ((timeinfo->tm_hour)>= 22) // 10PM Event
            //Do something here


Any suggested syntax appreciated.