Page 1 of 1

time format

Posted: Tue Feb 07, 2017 10:03 pm
by Bbuschke
I connected at 16x2 lcd to display time but it only shows time in 24hr format and i want 12 hr format. Any idea how i can change the pi's time format?

Re: time format

Posted: Tue Feb 07, 2017 10:09 pm
by CarlRJ
As with all Unix systems, the Pi's time format is seconds past midnight January 1st 1970, UTC. If you're seeing the time in some more human readable format, that is because of the program that you're running. That program is what needs changing.

Re: time format

Posted: Tue Feb 07, 2017 10:34 pm
by DougieLawson
It's the difference between

Code: Select all

  time (&rawtime);
  timeinfo = localtime (&rawtime);

  strftime (time_of_day,16,"%T %b,%d",timeinfo);
and

Code: Select all

  time (&rawtime);
  timeinfo = localtime (&rawtime);

  strftime (time_of_day,16,"%R %b,%d",timeinfo);
and

Code: Select all

  time (&rawtime);
  timeinfo = localtime (&rawtime);

  strftime (time_of_day,16,"%r %b,%d",timeinfo);
Most programming languages use those strftime() strings to choose the time/date formats.