Page 1 of 1

Show time in 12 hour (AM/PM) format

Posted: Mon Dec 05, 2016 7:54 am
by lewisg
As the subject title says, I'm wishing to display the time in a 12 hour (AM/PM) format.....can it be done?

Re: Show time in 12 hour (AM/PM) format

Posted: Mon Dec 05, 2016 2:23 pm
by dwhitfield
From https://assets.nagios.com/downloads/nag ... gmain.html
Format: date_format=<option>
Example: date_format=us

This option allows you to specify what kind of date/time format Nagios should use in the web interface and date/time macros.
In case that doesn't work for you, what version of Core are you using? Did you install it from repos or compile from source? On what OS/version are you running Core? This last question will help us figure out how date's are being processed on your system.

If that does work for you, is it ok if we go ahead and lock the thread?

Re: Show time in 12 hour (AM/PM) format

Posted: Mon Dec 05, 2016 4:58 pm
by lewisg
dwhitfield wrote:From https://assets.nagios.com/downloads/nag ... gmain.html
Format: date_format=<option>
Example: date_format=us

This option allows you to specify what kind of date/time format Nagios should use in the web interface and date/time macros.
In case that doesn't work for you, what version of Core are you using? Did you install it from repos or compile from source? On what OS/version are you running Core? This last question will help us figure out how date's are being processed on your system.

If that does work for you, is it ok if we go ahead and lock the thread?
Yeah, had that set already to date_format=us

The system is:
Nagios Core 4.21 ...... compiled from source.
Operating System: CentOS Linux 7 (Core) minimal
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64

Checking Google I received no joy.
Tried a few changes in php.ini and Apache's config files (SSI directives in particular) without success.

Re: Show time in 12 hour (AM/PM) format

Posted: Tue Dec 06, 2016 10:40 am
by dwhitfield
So, unfortunately, it looks like the answer is..."not easily."

The date format code is as follows:

Code: Select all

else if(!strcmp(variable, "date_format")) {

			if(!strcmp(value, "euro"))
				date_format = DATE_FORMAT_EURO;
			else if(!strcmp(value, "iso8601"))
				date_format = DATE_FORMAT_ISO8601;
			else if(!strcmp(value, "strict-iso8601"))
				date_format = DATE_FORMAT_STRICT_ISO8601;
			else
				date_format = DATE_FORMAT_US;
}
from https://github.com/NagiosEnterprises/na ... fig.c#L994

If you don't want to modify the code yourself, you can post a feature request at https://github.com/NagiosEnterprises/na ... issues/new

Is it ok if we go ahead and lock this up? The github feature request is a better place for people to explain why they want the feature than the forum post.

Re: Show time in 12 hour (AM/PM) format

Posted: Tue Dec 06, 2016 1:12 pm
by lewisg
Thanks, I'll play with changing the code in a sandbox install and also put in a feature request on github.
Closing thread.

Re: Show time in 12 hour (AM/PM) format

Posted: Tue Dec 06, 2016 2:38 pm
by dwhitfield
If you do come up with a fix, definitely post it on github, or just open a new thread. I'm really shocked this hasn't been a request in the past. You can't be the only person that prefers or has users that prefer AM/PM.