Date / Timestamp

Request and discuss new features you would like to have.
Post Reply
User avatar
BruceLeeRoy
Posts: 47
Joined: 01 May 2015 13:27

Date / Timestamp

Post by BruceLeeRoy »

Hard to search the Forum for date layout, not sure if there is a was to change the way Dates are displayed in the logs MM/DD/YYYY or MM/DD/YY is common in the US. Is this possible to change?
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: Date / Timestamp

Post by pdwalker »

upper right hand corner, click on your username,

- select user control panel
- select board preferences
- select edit global settings
- edit "my date format" to your liking
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: Date / Timestamp

Post by pdwalker »

or am I misunderstanding your question?
User avatar
BruceLeeRoy
Posts: 47
Joined: 01 May 2015 13:27

Re: Date / Timestamp

Post by BruceLeeRoy »

Oh, no I mean in EFA mail logs.
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: Date / Timestamp

Post by pdwalker »

Yes, I understand now.

The date stamp format for the log files is controlled rsyslogd, the message logging daemon. You'd need to create a new template with your preferred date format and restart rsyslogd.

See: http://www.rsyslog.com/doc/v8-stable/co ... lates.html but keep in mind that this is the documentation for v8 while efa/centos 6 is using version 5.8.10, so not all the examples may apply.

More useful information can be found here:
https://unix.stackexchange.com/question ... y-rsyslogd

Now, since you brought it to my attention, and reading the above links takes a fair bit of work, here is something you can add to /etc/rsyslog.conf to give you useful timestamps in YY-MM-DD HH:MM:SS format (the most useful format for human readable date formats in my not so humble opinion)

Code: Select all

#### GLOBAL DIRECTIVES ####
$template CustomFormat,"%TIMESTAMP:1:10:date-rfc3339% %TIMESTAMP:12:19:date-rfc3339% %HOSTNAME% %syslogtag%%msg%\n"

# Use default timestamp format
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$ActionFileDefaultTemplate CustomFormat
That shitty looking syntax can be broken down into the following
%TIMESTAMP% = the date format, which looks like "2017-07-24T12:30:50.373801+08:00"
%TIMESTAMP:1:10:date-rfc3339% means grab the characters 1 - 10
%TIMESTAMP:12:19:date-rfc3339% menas grab characters 12 - 19

Thus my final timestamp pulls out two substrings from the timestamp string
2017-07-24T12:30:50.373801+08:00

and that's good enough for me.

If you want American date formats, you can slice and dice your string until you have the format you want.

Also, I've specified the rfc3339 date format which includes high precision time and timezone, but only because that was the full date example that I quickly found in the documentation. There may be other date formats, but I don't have the time to look them up for you.

Have fun!

Edit: went and found the correct documentation anyway:
  1. https://rsyslog-5-8-6-doc.neocities.org ... lates.html
  2. https://rsyslog-5-8-6-doc.neocities.org ... lacer.html <-- the key bit
User avatar
BruceLeeRoy
Posts: 47
Joined: 01 May 2015 13:27

Re: Date / Timestamp

Post by BruceLeeRoy »

Thank you for the detailed explanation! I've been playing with the rsyslog and noticed the changes in the linux logfiles in /var/log but specifically I was referring to the entries in the web interface such as the "Recent Messages" and "Virus Report" which apparently aren't pulled from the standard logfiles? I'm sorry I should have been more specific.
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: Date / Timestamp

Post by pdwalker »

oh! that's easy!

edit your conf.php and search for DATE_FORMAT. That entry and the TIME_FORMAT entry following it can be set to whatever format you like.

I've just changed mine from:

Code: Select all

define('DATE_FORMAT', '%d/%m/%y');
to:

Code: Select all

define('DATE_FORMAT', '%Y-%m-%d');
Documentation on the formats can be found here: https://www.w3schools.com/sql/func_mysq ... format.asp
User avatar
BruceLeeRoy
Posts: 47
Joined: 01 May 2015 13:27

Re: Date / Timestamp

Post by BruceLeeRoy »

Wow, that was easy! Thanks!
Post Reply