Date Format differs

Discussions related to the 1.36.x series of ZoneMinder
jmynheir
Posts: 14
Joined: Fri Oct 05, 2018 6:24 am

Date Format differs

Post by jmynheir »

Fedora 34
Zoneminder 1.36.11
System Locale: LANG=en_US.UTF-8
Timezone GMT-6:00
US installation, however In the event list it shows date start time and end time in GB format. Is there a setting in ZM to change this?
I have monitor timestamp set to %m/%d/%y
zm.png
zm.png (18.79 KiB) Viewed 14860 times
zm2.png
zm2.png (25.01 KiB) Viewed 14860 times
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Date Format differs

Post by Magic919 »

Start with Options > System > TZ. You might need to ensure PHP agrees.
-
fahnoe
Posts: 11
Joined: Tue Feb 15, 2011 1:32 pm

Re: Date Format differs

Post by fahnoe »

I have the same issue: event start/end times are displayed in dd/mm/yy format rather than the typical (for the US) mm/dd/yy format.
  • Options > System > TIMEZONE is set to (GMT-6:00) America, Chicago
  • php.ini has date.timezone = America/Chicago
  • Zoneminder server and database server are both set to America/Chicago
Am I correct in thinking that this is a long standing issue with Zoneminder?

--Larry
User avatar
iconnor
Posts: 2912
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Date Format differs

Post by iconnor »

You set the timestamp format under Monitor->Timestamp
fahnoe
Posts: 11
Joined: Tue Feb 15, 2011 1:32 pm

Re: Date Format differs

Post by fahnoe »

Sorry, I'm referring to the events display on the web interface, the monitor date format seems to have no impact upon this:

Screen Shot 2021-12-15 at 06.40.39.png
Screen Shot 2021-12-15 at 06.40.39.png (55.9 KiB) Viewed 14762 times


Any chance this is related to the 1.36.11 change:
- Set Locale for time to en_GB.utf8, changed STRF_FMT_DATETIME_SHORTER to %x which is locale aware short date

--Larry
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: Date Format differs

Post by kitkat »

I wish I could get UK date formats here!
Untitled-1.png
Untitled-1.png (8.73 KiB) Viewed 14727 times
1.36.10 on CentOS.


e2a: Turns out I can :)

The clue was STRF_FMT_DATETIME_SHORTER above and the solution was to edit /usr/share/zoneminder/www/includes/lang.php and change the definition from '%m/%d %H:%M:%S' to '%d/%m %H:%M:%S'

I guess this might fix itself (at least for me) in 1.36.11 and higher, but I'm waiting for .12.
ScottyG
Posts: 6
Joined: Sat May 22, 2021 12:33 am

Re: Date Format differs

Post by ScottyG »

I am on 1.36.12 Focal and have the same issue...
fahnoe
Posts: 11
Joined: Tue Feb 15, 2011 1:32 pm

Re: Date Format differs

Post by fahnoe »

I don't know the history of the codebase, but upon further investigation it appears odd to me that /usr/share/zoneminder/www/lang/en_us.php includes /usr/share/zoneminder/www/lang/en_gb.php which defines setlocale( LC_TIME, 'en_GB.utf8' ), but then does not update the locale to the US.

A simple fix, but one that probably won't survive updates is:

Code: Select all

--- /usr/share/zoneminder/www/lang/en_us.php~	2021-11-17 10:05:50.000000000 -0600
+++ /usr/share/zoneminder/www/lang/en_us.php	2021-12-23 06:41:10.854389147 -0600
@@ -69,6 +69,8 @@
 // setlocale( LC_CTYPE, 'en_GB' ); Character class settings 4.3.0 and after
 // setlocale( LC_TIME, 'en_GB' ); Date and time formatting 4.3.0 and after
 
+setlocale( LC_TIME, 'en_US.utf8' );
+
 // Simple String Replacements
 $SLANG['24BitColour']          = '24 bit color';
 $SLANG['32BitColour']          = '32 bit color';
--Larry
twcamsec
Posts: 5
Joined: Fri Apr 14, 2017 2:01 am

Re: Date Format differs

Post by twcamsec »

Thank you for posting your findings and the fix!
User avatar
iconnor
Posts: 2912
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Date Format differs

Post by iconnor »

The language stuff could use a cleanup.

I'll get that setlocale into master and 1.36.13, but really more needs to be done.

Ideally the language would set a default, but then in config, and in User settings should be overrideable.

I wonder if we really even need to set a default. Should it use the system default?
User avatar
AllenTuttle
Posts: 29
Joined: Tue Sep 25, 2007 4:56 pm
Location: Sequim WA.

Re: Date Format differs

Post by AllenTuttle »

So, even if we have to edit after every update, is there a way to get the Date string in the various views to be Day/Month/Year?
I edited many of the php's changing %d/%m/%y to %y/%m/%d but none had any effect even after restarting httpd and zoneminder.
The only change that had any impact was adding "setlocale( LC_TIME, 'en_US.utf8' )" to en_us.php but all id did was change the year format from 2 digits to 4.
cbeaumont
Posts: 1
Joined: Thu Apr 07, 2022 7:06 pm

Re: Date Format differs

Post by cbeaumont »

I'm stuck in the d-m-y format too. Monitor>Timestamp shows %N - %y-%m-%d %H:%M:%S %z but doesn't effect event format.

I did have to fight with utf8mb4 vs utf8 a bit after a crash and frustrating rebuild.

Ubuntu 18.04.6 LTS, mysql Ver 15.1 Distrib 10.7.3-MariaDB, zoneminder v1.36.13
Language is en-us, Timezone is Los Angeles.
RonRN18
Posts: 52
Joined: Tue Aug 13, 2019 1:00 am

Re: Date Format differs

Post by RonRN18 »

fahnoe wrote: Thu Dec 23, 2021 1:09 pm I don't know the history of the codebase, but upon further investigation it appears odd to me that /usr/share/zoneminder/www/lang/en_us.php includes /usr/share/zoneminder/www/lang/en_gb.php which defines setlocale( LC_TIME, 'en_GB.utf8' ), but then does not update the locale to the US.

A simple fix, but one that probably won't survive updates is:

Code: Select all

--- /usr/share/zoneminder/www/lang/en_us.php~	2021-11-17 10:05:50.000000000 -0600
+++ /usr/share/zoneminder/www/lang/en_us.php	2021-12-23 06:41:10.854389147 -0600
@@ -69,6 +69,8 @@
 // setlocale( LC_CTYPE, 'en_GB' ); Character class settings 4.3.0 and after
 // setlocale( LC_TIME, 'en_GB' ); Date and time formatting 4.3.0 and after
 
+setlocale( LC_TIME, 'en_US.utf8' );
+
 // Simple String Replacements
 $SLANG['24BitColour']          = '24 bit color';
 $SLANG['32BitColour']          = '32 bit color';
--Larry
Thanks, Larry, that fixes my frustration for the moment. Hopefully, an update doesn't bork it. As it is only on my local machine, I altered both /usr/share/zoneminder/www/lang/en_us.php and /usr/share/zoneminder/www/lang/en_gb.php to +setlocale( LC_TIME, 'en_US.utf8' );. I don't think there will be an issue with it being told twice to use the US date version (as /usr/share/zoneminder/www/lang/en_us.php calls for "require_once( 'lang/en_gb.php'").
tinymouse
Posts: 23
Joined: Sat Apr 02, 2022 11:36 pm

Re: Date Format differs

Post by tinymouse »

I have the same issue. My change was to copy en_gb.php to en_us.php.new and change lines 72 & 74

Line 72: setlocale( LC_TIME, 'en_US.utf8' );
Line 74: define( "STRF_FMT_DATETIME_SHORT", "%m/%d/%Y %H:%M:%S" );

Then save with the .new so I can re-copy over to the en_us.php
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: Date Format differs

Post by kitkat »

AllenTuttle wrote: Thu Mar 03, 2022 12:07 am So, even if we have to edit after every update, is there a way to get the Date string in the various views to be Day/Month/Year?
Changing the definition of STRF_FMT_DATETIME_SHORTER in /usr/share/zoneminder/www/includes/lang.php from '%m/%d %H:%M:%S' to '%d/%m %H:%M:%S' worked to give me DD/MM instead of MM/DD in the event view, so maybe changing STRF_FMT_DATE in the same file to something other than '%x' would work (e.g. '%d/%m/%y %H:%M:%S').
Post Reply