Tuesday 14 August 2012

Using ISO 8601 Date on Ubuntu

Ubuntu ships with GNU's date version 8.13, which has an option --iso-8601. This is a great format for appending to logs. It is internationally unambiguous and english sorting order is the same as chronological order.

Unfortunately this option is not documented in Ubuntu's man page or info page for date.

The example output of "date --iso-8601=seconds" is
 

2012-08-14T20:40:55+1000


Alternatively with GNU date you can use "date +%FT%R:%S%z". 

Of course there is always the POSIX standard "date +%Y-%m-%dT%H:%M:%S%z"

No comments:

Post a Comment