login or register
u
p
 remember me!
ISO 8601
prints friendly
ISO 8601


please note:
- the text and code below is from The Pseudopedia
- it has been imported raw for GetWiki
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. It was issued by the International Organization for Standardization (ISO) and was first published in 1988. The purpose of this standard is to provide an unambiguous and well-defined method of representing dates and times, so as to avoid misinterpretation of numeric representations of dates and times, particularly when data is transferred between countries with different conventions for writing numeric dates and times.The standard organizes the data so the largest temporal term (the year) appears first in the data string and progresses to the smallest term (the second). It also provides for a standardized method of communicating time-based information across time zones by attaching an offset to Coordinated Universal Time (UTC).(1){| class="infobox" style="text-align: center;"| Date and time (current at page generation)
expressed according to ISO 8601:| Date
| {{#time: Y-m-d }}
| Separate date and time in UTC:
| {{#time: Y-m-d h:i"Z"}}
| Combined date and time in UTC:
| {{#time: Y-m-d"T"h:i"Z"}}
| Date with week number:
| {{#time: Y-"W"W-N}}
| Ordinal date:
{{#time: o}}-{{padleft:{{#expr:{{#time: z}}+1}}>3}}

History

The first edition of the ISO 8601 standard was published in 1988. It unified and replaced a number of older ISO standards on various aspects of date and time notation: ISO 2014, ISO 2015, ISO 2711, ISO 3307, and ISO 4031.WEB
,weblink
, ISO 8601:2004(E)
, 2010-03-07
, 2004-12-01
, International Organization for Standardization, ISO
, Annex A … From that concept representations of all other date and time values were logically derived; thus, ISO 2014, ISO 3307 and ISO 4031 have been superseded. … Identification of a particular date by means of ordinal dates (ISO 2711) and by means of the week numbering system (ISO 2015) were alternative methods that the basic concept of this International Standard could also encompass; thus, ISO 2015 and ISO 2711 have now been superseded., It has been superseded by a second edition in 2000 and by the current third edition published on 3 December 2004.
ISO 2014 was the standard that originally introduced the big-endian all-numeric date notation {{nowrap|[YYYY]-[MM]-[DD]}}. The ISO week numbering system was introduced in ISO 2015, and the identification of days by ordinal dates was originally defined in ISO 2711.It is maintained by ISO Technical Committee TC 154.(2)

General principles

  • Date and time values are organized from the most to the least significant: year, month (or week), day, hour, minute, second, and fraction of second. The lexicographical order of the representation thus corresponds to chronological order, except for date representations involving negative years.
  • Each date and time value has a fixed number of digits that must be padded with leading zeros.
  • Representations can be done in one of two formats—a basic format with a minimal number of separators or an extended format with separators added to enhance human readability.(3) The separator used between date values (year, month, week, and day) is the hyphen, while the colon is used as the separator between time values (hours, minutes, and seconds). For example, the 6th day of the 1st month of the year 2009 may be written as {{nowrap|"2009-01-06"}} in the extended format or simply as "20090106" in the basic format without ambiguity. The extended formats are preferred over the basic formats not only for human readability, but because some basic formats can appear to be ambiguous to those unfamiliar with the standard.
  • For reduced accuracy, any number of values may be dropped from any of the date and time representations, but in the order from the least to the most significant. For example, "2004-05" is a valid ISO 8601 date, which indicates the 5th month of the year 2004. This date will never represent the 5th day of some unknown month in 2004.
  • When higher precision is needed, the standard supports the addition of a decimal fraction to the smallest time value in the representation.

Dates

{{CURRENTCALENDAR}}The standard uses the Gregorian calendar, which is the most widely used calendar in the world and is already the de facto standard of international trade.As a point of interest, ISO 8601 fixes a reference calendar date to the Gregorian calendar of {{nowrap|1875-05-20}} as the date the Convention du Mètre (Metre Convention) was signed in Paris. However, ISO calendar dates before the Convention are still compatible with the Gregorian calendar all the way back to the official introduction of the Gregorian calendar on {{nowrap|1582-10-15}}. Earlier dates, in the proleptic Gregorian calendar, may be used by mutual agreement of the partners exchanging information. The standard states that every date must be consecutive, so usage of the Julian calendar would be contrary to the standard (because at the switchover date, the dates would not be consecutive).YYYY">

Years{| class"infobox" style"text-align:center; width:25em;"| YYYY

| ±YYYYY
ISO 8601 prescribes, as a minimum, a four-digit year [YYYY] to avoid the
year 2000 problem.To represent years before 0000 or after 9999, the standard also permits the expansion of the year representation [±YYYYY], but only by prior agreement between the sender and the receiver.(4) An expanded year representation must have an agreed-upon number of extra year digits beyond the four-digit minimum and is always prefixed with a + or − sign with the convention that year zero is positive.The common BC/BCE notation, for dates that are before year 0001, is not used. For instance, the year 3 BC can be denoted by −0002.(5) (There is a difference of 1 because the BC system has no year zero.)YYYY-MM-DD >or>| YYYYMMDD">

Calendar dates{| class"infobox" style"text-align: center; width: 25em"YYYY-MM-DD >or>| YYYYMMDD

| YYYY-MM
(but not YYYYMM)
Calendar date representations are in the form as shown in the box to the right. [YYYY] indicates a four-digit year, 0000 through 9999. [MM] indicates a two-digit month of the year, 01 through 12. [DD] indicates a two-digit day of that month, 01 through 31. For example, "the 5th of April 1981" may be represented as either {{nowrap|"1981-04-05"}} in the extended format or "19810405" in the basic format.The standard also allows for calendar dates to be written with reduced precision. For example, one may write {{nowrap|"1981-04"}} to mean "1981 April", and one may simply write "1981" to refer to that year or "19" to refer to that century.Although the standard allows both the YYYY-MM-DD and YYYYMMDD formats for complete calendar date representations, if the day [DD] is omitted then only the {{nowrap|YYYY-MM}} format is allowed. By disallowing dates of the form YYYYMM, the standard avoids confusion with the truncated representation YYMMDD (still often used).

Week dates

{| class="infobox" style=" text-align:center; width:25em;"YYYY-Www >or>| YYYYWww
YYYY-Www-D >or>| YYYYWwwD
Week date representations are in the format as shown in the box to the right. [YYYY] indicates the ISO week-numbering year which is slightly different to the calendar year (see below). [Www] is the week number prefixed by the letter 'W', from W01 through W53. [D] is the weekday number, from 1 through 7, beginning with Monday and ending with Sunday. This form is popular in the manufacturing industries.There are mutually equivalent descriptions of week 01:
  • the week with the year's first Thursday in it (the formal ISO definition),
  • the week with 4 January in it,
  • the first week with the majority (four or more) of its days in the starting year, and
  • the week starting with the Monday in the period 29 December – 4 January.
If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year (there is no week 00). 28 December is always in the last week of its year.The week number can be described by counting the Thursdays: week 12 contains the 12th Thursday of the year.The ISO week-numbering year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year (hence without overlap or gap). It consists of 52 or 53 full weeks. The ISO week-numbering year number deviates from the number of the calendar year (Gregorian year) on a Friday, Saturday, and Sunday, or a Saturday and Sunday, or just a Sunday, at the start of the calendar year (which are at the end of the previous ISO week-numbering year) and a Monday, Tuesday and Wednesday, or a Monday and Tuesday, or just a Monday, at the end of the calendar year (which are in week 01 of the next ISO week-numbering year). For Thursdays, the ISO week-numbering year number is always equal to the calendar year number.Examples:
  • 2008-12-29 is written "{{ISOWEEKDATE|2008|12|29}}"
  • 2010-01-03 is written "{{ISOWEEKDATE|2010|01|03}}"
For an overview of week numbering systems see week number. The US system has weeks from Sunday through Saturday, and partial weeks at the beginning and the end of the year. An advantage is that no separate year numbering like the ISO week-numbering year is needed, while correspondence of lexicographical order and chronological order is preserved.YYYY-DDD >or>| YYYYDDD">

Ordinal dates{| class"infobox" style"text-align:center; width:25em;"YYYY-DDD >or>| YYYYDDD

An Ordinal date is a simple form for occasions when the arbitrary nature of week and month definitions are more of an impediment than an aid, for instance, when comparing dates from different calendars. As represented above, [YYYY] indicates a year. [DDD] is the day of that year, from 001 through 365 (366 in leap years). For example, {{nowrap|"1981-04-05"}} is also {{nowrap|"1981-095"}}.This format has particular use for simple hardware systems that have need of a date system, but where including full calendar calculation software may be a significant nuisance. This system is sometimes incorrectly referred to as "Julian Date", while the astronomical Julian Date is a straight leap number date originating from January 1, 4713 BC Greenwich noon, Julian proleptic calendar (or, noon on ISO date {{nowrap|-4712-01-01}}).hh:mm:ss >or>| hhmmss">

Times{| class"infobox" style"text-align: center; width: 25em"hh:mm:ss >or>| hhmmss

hh:mm >or>| hhmm
| hh
ISO 8601 uses the 24-hour clock system. The basic format is [hh][mm][ss] and the extended format is [hh]:[mm]:[ss].
  • [hh] refers to a zero-padded hour between 00 and 24 (where 24 is only used to notate midnight at the end of a calendar day).
  • [mm] refers to a minute between 00 and 59.
  • [ss] refers to a second between 00 and 60 (where 60 is only used to notate an added leap second).
So a time might appear as either "134730" in the basic format or "13:47:30" in the extended format.It is also acceptable to omit lower order time elements for reduced accuracy: [hh]:[mm], [hh][mm] and [hh] are all used.Midnight is a special case and can be referred to as both "00:00" and "24:00". The notation "00:00" is used at the beginning of a calendar day and is the more frequently used. At the end of a day use "24:00". Note that "2007-04-05T24:00" is the same instant as "2007-04-06T00:00" (see Combined date and time representations below).Decimal fractions may also be added to any of the three time elements. A decimal point, either a comma or a dot (without any preference as stated most recently in resolution 10 of the 22nd General Conference CGPM in 2003), is used as a separator between the time element and its fraction. A fraction may only be added to the lowest order time element in the representation. To denote "14 hours, 30 and one half minutes", do not include a seconds figure. Represent it as "14:30,5" or "1430,5". There is no limit on the number of decimal places for the decimal fraction. However, the number of decimal places needs to be agreed to by the communicating parties.

Time zone designators

There are no time zone designators in ISO 8601. Time is only represented as local time or in relation to UTC.{| class="infobox" style="width: 25em"|
or>| '''
|
If no UTC relation information is given with a time representation, the time is assumed to be in local time. While it may be safe to assume local time when communicating in the same time zone, it is ambiguous when used in communicating across different time zones. It is usually preferable to indicate a time zone (zone designator) using the standard’s notation.

UTC

If the time is in UTC, add a 'Z' directly after the time without a space. 'Z' is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".UTC time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic alphabet word for 'Z'.

Time offsets from UTC

The offset from UTC is given in the format ±[hh]:[mm], ±[hh][mm], or ±[hh]. So if the time being described is one hour ahead of UTC (such as the time in Berlin during the winter), the zone designator would be "+01:00", "+0100", or simply "+01". This is appended to the time in the same way that 'Z' was above. The offset from UTC changes with daylight saving time, e.g. a time offset in Chicago, would be "-06:00" for the winter (Central Standard Time) and "-05:00" for the summer (Central Daylight Time).The following times all refer to the same moment: "18:30Z", "22:30+04", "1130-0700", and "15:00-03:30". Nautical time zone letters are not used with the exception of Z. To calculate UTC time one has to subtract the offset from the local time, e.g. for "15:00-03:30" do 15:00 − (−03:30) to get 18:30 UTC.The offset can also be used in the case where the UTC time is known, but the local offset is not. In this case the offset is "-00:00", which is semantically different from "Z" or "+00:00", as these imply that UTC is the preferred reference point for those times.(6)T

Combined date and time representations{| class"infobox" style"width: 25em"| T| T

Combining date and time representations to represent a single point in time (time point) is quite simple. It is in the format of T