How create an identical timestamp format as used in ppp.log file in a shell script? In the need to add custom logging messages to ppp.log, I see that the date and time are missing when outputting the command to &gt;&gt; /var/log/ppp.log. Other pppd related messages in ppp.log are prepended with a timestamp format that is similar to: &quot;Sat Apr  9 17:18:02 2016 : &quot;. My goal is to output this exact date time format in a Mavericks shell script
I know that other log files have different date/time timestamps. I want to re-create the format as used in ppp.log.
Regression
This Mac OS X 10.9 environment is configured with a dutch language locale. Therefore $ echo $(date '+%a') returns &quot;za&quot; instead of the desired &quot;Sat&quot;. That is the part that can be fixed by export LC_TIME=&quot;C&quot; or export LC_TIME=&quot;POSIX&quot;. I have tried to read the date and pppd man page. However then there is still the abbreviated alphabetic timezone name CEST (the %Z part in $ date +%Z) in the output &quot;Sat Apr  9 18:12:12 CEST 2016&quot;.
I know I can create the format using all the different $ date format codes, like %a %b %e etcetera. Though I guess there is  a shorter way, isn't there?
After a lot of searching, a search for &quot;date format without alphabetic time zone abbreviation&quot; returned Info on ISO 8601, the date and time representation standard. That information helped me to find out that the timestamp format that is being used in Mavericks its /private/var/log/ppp.log file, is actually the ANSI C's asctime() format.
C asctime
To create C style asctime in a shell, a non English system might need to override the environment variable for time messages:
export LC_TIME=&quot;C&quot;

And then there is the $ date formatting option %c that now displays local date time in the desired format:
$ date +%c
Sat Apr  9 21:10:20 2016


A tip when using echo date, do put the date between apostrophes echo &quot;$(date +%c)&quot;, otherwise the filler space in single digit dates might be stripped from the output:
$ echo $(date +%c)
Sat Apr 9 21:13:57 2016
$ echo &quot;$(date +%c)&quot;
Sat Apr  9 21:14:30 2016