Chat freely about anything...

User avatar
By Stewart
#83119 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;
      time(&now);
      timeinfo = localtime(&now);
      Serial.println(timeinfo->tm_hour);
        if ((timeinfo->tm_hour)>= 22) // 10PM Event
            //Do something here


Reference:
https://www.jtbullitt.com/tech/cheats/ctime-cheat-sheet.pdf

Any suggested syntax appreciated.