Unix Date Conversion

These notes include variations for the GNU date implemenation where it differs from the Unix date implementation.

Examples

Current date:

$ date

Current date UTC:

$ date -u

Current date formatted as YYYY-MM-DD hh:mm:

$ date '+%F %R'
$ date '+%Y-%m-%d %H:%M'

Current date formatted as ISO 8601

$ date -Iseconds

Current date as number of seconds since the Epoch:

$ date +%s

Print date as number of seconds since the Epoch:

$ date -j -f '%Y-%m-%dT%H:%M:%S%z' '2020-01-31T23:00:00+0000' +%s

with the GNU date implementation:

$ date -d '2020-01-31T23:00:00+0000' +%s

Print date based on seconds since Epoch:

$ date -r 1580511600
$ date -r 1580511600 +%Y-%m-%dT%H:%M:%S%z

with the GNU date implementation:

$ date -d '@1580511600'
$ date -d '@1580511600' +%Y-%m-%dT%H:%M:%S%z

Parse a date string:

$ date -j -f '%Y-%m-%dT%H:%M:%S%z' '2020-01-31T23:00:00+0000'
$ date -j -f '%F %R' '2020-01-31 23:00'

$ strtime=2020-01-31T23:00:00+0000
$ date -j -f '%Y-%m-%dT%H:%M:%S%z' ${strtime:0:22}${strtime:23:2}

with the GNU date implementation:

$ date -d '2020-01-31T23:00:00+0000'

Resources


-- Frank Dean - 14 Jun 2026

Related Topics: JavaDateConversion, LinuxHintsAndTips