Skip to content


Notes about time technologies.

ISO 8601

ISO 8601 Data elements and interchange formats - Information interchange - Representation of dates and times is an international standard covering the exchange of date and time-related data.

ISO 8601 format examples

See the ISO 8601 wikipedia page for many examples. Much of the content in this section was taken from that article.

There are a ton of examples on this page:

One notable syntax is that the letter T should always precede times. This aids in parsing, and distinguishes between month and minute, which are both shortened to M.

Another notable syntax is the use of Z to mean a timezone offset of 0 hours, or GMT.

Single points in time

$ for fmt in date hours minutes seconds ns  ; do
    bash -x -c "
        awk '$1 !~ /^#/ {print $3}' /usr/share/zoneinfo/ |
        sort -R |
        head -n 1
      ) \
      date --iso-8601=${fmt}
    " ;
  done ;
+ TZ=America/Paramaribo
+ date --iso-8601=date
+ TZ=Africa/Dakar
+ date --iso-8601=hours
+ TZ=Indian/Kerguelen
+ date --iso-8601=minutes
+ TZ=Pacific/Saipan
+ date -Iseconds
+ TZ=Pacific/Midway
+ date --iso-8601=ns
  • Week: 2016-W32
  • Date with week number: 2016-W32-2
  • Month and day without year: -12-31

Durations, or ranges of time

Durations are a component of time intervals and define the amount of intervening time in a time interval.

  • P10Y - a duration of ten years.
  • P5DT12H - a duration of five days and twelve hours.
  • P3Y6M4DT12H30M5S - a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.
  • P1M - one month.
  • PT1M - one minute.

Time intervals

A time interval is the intervening time between two time points. There are four ways to express a time interval:

  • Start and end, such as 2007-03-01T13:00:00Z/2008-05-11T15:30:00Z
  • Start and duration, such as 2007-03-01T13:00:00Z/P1Y2M10DT2H30M
  • Duration and end, such as P1Y2M10DT2H30M/2008-05-11T15:30:00Z
  • Duration only, such as P1Y2M10DT2H30M, with additional context information

Repeating intervals

Repeating intervals are formed by adding R[n]/ to the beginning of an interval expression. Such as R5/2007-03-01T13:00:00Z/2008-05-11T15:30:00Z. The n can be omitted if the interval should repeat forever.

RFC 3339

RFC 3339 is considered a profile of ISO 8601. It defines a profile of ISO 8601 for use in Internet protocols and standards. It explicitly excludes durations and dates before the common era. The more complex formats such as week numbers and ordinal days are not permitted.

Leap Seconds

"A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC) in order to keep its time of day close to the mean solar time, or UT1." -

Leap seconds are scheduled by the international earth rotation and reference systems service (See also: Leap seconds cause a variety of problems in computer systems, and complicate time tracking in general.

Public time server handling of leap seconds

Code snips and examples

Quick and dirty time sync in Linux for when NTP is blocked.

date -s $(curl -s -D - | sed '/Date:/s/.*Date: //p ; d')



See Also

  • ntp - Network Time Protocol
  • ptp - Precision Time Protocol