timeformat 12-hr clock with AM or PM

63 views
Skip to first unread message

Rod in Edm

unread,
Feb 7, 2026, 9:12:46 PM (2 days ago) Feb 7
to weewx-user
Long time WView/Weewx user. Running Weewx 5.2.0 / Seasons skin 5.2.0 on RPi4B with RaspberryPi OS 64-bit Trixie. Fresh install of Trixie / Weewx 5.2.0 on Pi4, using Weewx Simulator for now (Vantage 2 is real hardware target). Locale configured on Weewx install as Ottawa (Canada) and Edmonton/America, English (essentially MST).

Trying to format report and graphical image time  to give me "12:05:34 PM". To get this in reports, I'm replacing "%x.%X" in weewx,conf => StdReport => Defaults => Units => TimeFormats with

hour        = %I:%M:%S %p
etc

and then restarting weewx (and when that didn't work, stopping weewx and rebooting the RPi4B). I'm getting "12:05:34 pm",  instead of "12:05:34 PM" in my reports.

Since Weewx uses strftime() directives to format time, and that function's manual page shows "%p" as the format for "PM". I'm not sure what's going on. After reading the strftime() directives doc more carefully, I figured I'd try "%P" ... but that didn't make any difference. I get that locale plays a role in this formatting.

NOT the end of the world, but annoying that I can't dope out what appears to be a simple problem. Did a search of the forum posts using a mixture of keywords, but I don't see anything relevant - so I assume I'm just doing something stupid.

What am I missing here? 
Rod

p q

unread,
Feb 7, 2026, 9:54:01 PM (2 days ago) Feb 7
to weewx...@googlegroups.com
I have %-I:%M %p and I get uppercase AM/PM.

I asked Claude.ai and it says (and I'm not sure I believe it!) that %p gives uppercase AM/PM and %P gives lowercase on Linux. 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/81164eb0-9295-4eb7-a5ed-39ec81bc9926n%40googlegroups.com.


--
Peter Quinn
(415)794-2264

Rod in Edm

unread,
Feb 7, 2026, 10:08:08 PM (2 days ago) Feb 7
to weewx-user
Thx, Peter. Yeah I read elsewhere (Stackflow?) that the p and P are flipped from what's intuitive.  Wierd.

Nate Bargmann

unread,
Feb 7, 2026, 10:43:08 PM (2 days ago) Feb 7
to weewx...@googlegroups.com
I didn't use the %p/%P but I have this which appears at the top of my
customized Standard kin:

<h2>$current.dateTime.format(format_string="%a %d %b %Y %H:%M %Z (%z)")</h2>

The result is:

Sat 07 Feb 2026 21:35 CST (-0600)

I do a similar format for the images:

bottom_label_format = %a %d %b '%y %H:%M %Z

Which becomes:

Sat 07 Feb '26 21:35 CST

I guess since I opted for 24 hour time and adding the time zone I didn't
see the issue you are.

- Nate

--
"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."
Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

signature.asc

Vince Skahan

unread,
Feb 7, 2026, 11:33:36 PM (2 days ago) Feb 7
to weewx-user
$current.dateTime.format(format_string="%c") works nicely for me.....

Sat 07 Feb 2026 08:30:00 PM PST

Rod in Edm

unread,
Feb 8, 2026, 1:25:54 AM (yesterday) Feb 8
to weewx-user
Huh ... all your responses suggest that it must be my "locale" settings that are doing this to me.

My aging RPi3B running Weewx 5.2.0 and Seasons 4.6.2 shows the right date-time format, and my new setup doesn't. There's hardly any difference between them (as far as I know), so the locale setting must be issue.

Using Terminal (I'm on a Mac), I' entered "locale" on both systems. I'm frustrated by what I see:

Old RPi3B system: locale displays as en.CA.UTF-8
New RPi4B system: locale displays as en.GB.UTF-8  {WTH?!?}

I must have fat-fingered the Weewx configuration during the install process. I'll change the new system locale to be en.CA.UTF-8 and see what happens. I'm pretty sure this is my problem, and if it is I'll come back here and confirm it to close this thread off.

I hate it when I turn out to be my problem. ¯\_(ツ)_/¯ 
Rod

Rod in Edm

unread,
Feb 8, 2026, 2:16:52 AM (yesterday) Feb 8
to weewx-user
Yup, that was it: my locale was set up wrong for the fresh Weewx install. I guess GB uses the lowercase "am" and "pm".

I think when I was installing Weewx on the RPi, I must have not saved my en.CA locale selection from the list. The default on an RPi is en.GB.

Thx all for being my sounding board.
Rod

John Smith

unread,
Feb 8, 2026, 4:25:43 AM (yesterday) Feb 8
to weewx...@googlegroups.com
I must have fat-fingered the Weewx configuration during the install process

No, that's the default setting for rpi's and the locale needs to be changed after installation finishes.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Nate Bargmann

unread,
Feb 8, 2026, 5:19:05 AM (yesterday) Feb 8
to weewx...@googlegroups.com
* On 2026 08 Feb 01:17 -0600, Rod in Edm wrote:
> Yup, that was it: my locale was set up wrong for the fresh Weewx install. I
> guess GB uses the lowercase "am" and "pm".
>
> I think when I was installing Weewx on the RPi, I must have not saved my
> en.CA locale selection from the list. The default on an RPi is en.GB.

No, it's deeper than WeeWX as the locale is system wide.

On the Pi use raspi-config:

https://www.raspberrypi.com/documentation/computers/configuration.html

This link shows where toe set the locale:

https://www.raspberrypi.com/documentation/computers/configuration.html#localisation-options

HTH,
signature.asc

Rod in Edm

unread,
Feb 8, 2026, 3:24:50 PM (20 hours ago) Feb 8
to weewx-user
You're both right, of course. The locale is set when installing the PiOS - I'd forgotten where in the whole process I chose it. The ECC bits in my wetware memory banks are failing, I guess.

To fix my am/AM problem, I used a couple Terminal commands to select the proper locale, and rebooted - never touched raspi-config:

<sudo dpkg-reconfigure locales>   then
<sudo locale-gen>   then rebooted

Confirmed proper locale by running CLI "locale" again, and double-checking by running "env | grep LANG".

Thanks again, all. Good help here!
Rod
Reply all
Reply to author
Forward
0 new messages