[Solved] Changing date format from GB to US but keep 24hr time

General support for the Pi-Star System
Post Reply
W3KIT
Posts: 58
Joined: Wed Jun 20, 2018 11:42 pm

[Solved] Changing date format from GB to US but keep 24hr time

Post by W3KIT »

Is there a way to change the date to US format but keep the 24 hr clock?

I would like the Nextion screen to displays:

10/25/2019 16:59:59 rather than 10/25/2019 04:59:59 PM

Thanks, W3KIT
Last edited by W3KIT on Sat Oct 26, 2019 1:52 pm, edited 1 time in total.
W3KIT
Posts: 58
Joined: Wed Jun 20, 2018 11:42 pm

Re: CHanging date format from GB to US but keep 24hr time

Post by W3KIT »

KE7FNS wrote: Sat Oct 26, 2019 12:39 am
I'd have to say, no.

I could explain how to modify the en_US locale to get the RPI to display the format you want but for some unknown reason MMDVMHost uses some other way than the locale to define the format for the time. I'm not sure where its getting it from either.
Ummm, that is probably why I am seeing the different between 2 of my hostspots.

One is P0 with Zumspot hat and the other is P0 with HS_hat. Both have the same 2.4" Nextion, loaded with the same TFT and both locale has been changed to US.

The Zumspot showing US date format and AM/PM clock. The HS_hat is showing 24 hr clock. Not sure what to make of it either.

Thanks, W3KIT
W3KIT
Posts: 58
Joined: Wed Jun 20, 2018 11:42 pm

Re: CHanging date format from GB to US but keep 24hr time

Post by W3KIT »

KE7FNS wrote: Sat Oct 26, 2019 2:43 am
If there is a difference, its more than likely you are comparing two different major releases of pi-star. The old 3.4.17 runs on a much older raspbian. 4.0 uses a different one , and 4.1 uses an even newer one.


I figured out how to do what you wanted now, I don't know why it wasn't cooperating for me earlier when I tried.

Thanks for the code, I will try it today when I get home.

BTW, all of my hotspots are running 4.1 RC6 20191016

Thanks, W3KIT
W3KIT
Posts: 58
Joined: Wed Jun 20, 2018 11:42 pm

Re: CHanging date format from GB to US but keep 24hr time

Post by W3KIT »

Got it to work now.

However %R is listed under SENEGAL (SN) (ff_SN) and it will only displaying 23:59 (missing sec).

So I forced the t_fmt to %T UNITED KINGDOM (GB) (en_GB) to displays 23:59:59

Regardless, thank you very much for paving the way for me.

Thanks, W3KIT
W3KIT
Posts: 58
Joined: Wed Jun 20, 2018 11:42 pm

Re: [Solved] Changing date format from GB to US but keep 24hr time

Post by W3KIT »

KE7FNS wrote: Sun Oct 27, 2019 12:55 am

You are looking at it backwards, don't look at %R and which locale it is used in, look at how the time is being formatted using "date".

Code: Select all

man date
%r locale's 12-hour clock time (e.g., 11:11:04 PM)

%R 24-hour hour and minute; same as %H:%M

%T time; same as %H:%M:%S

where
%H hour (00..23)
%M minute (00..59)
%S second (00..60)

Maybe I did not said it clearly :)

Originally, I was looking for 24 hours time format (%H:%M:%S), when I tried what you suggested in the code few posts up the thread to replace %r with %R. With the %R I get the 24 hours time format but like you said, only %H:%M is showing, no second.

As I was searching then I came across this site https://lh.2xlibre.net/values/t_fmt/

And I realized I could use anything in the t_fmt line, so I use %T instead of %R to get all %H:%M:%S not just %H:%M

Surprisingly, the only locale time format that is using %R is Senegal. At least from the listing anyway.

So, you did help me accomplished what I was looking for and I do thank you.

Thanks, W3KIT
Post Reply