ISO-8601 standard was created with the objective of elaborating a crystal clear language to talk about dates and periods and avoid misinterpretation. Here are some tips on possible pattern usage:

- Dates can be defined in format
**YYYY-MM-DD,**with a specific**D**ay,**M**onth and**Y**ear. Ex: 2019-04-12, means 12th April from 2019. - It is also possible to use for example,
**YYYY-MM,**necessarily with “-” in between years and month. Ex: 2019-04, means April from 2019. - Use
**-MM-DD**, necessarily with two dashes, to represent a day and a month. Ex. -04-12, means 12th April. - The time is represented in format
**[hh][mm][ss]**or**[hh]:[mm]:[ss]**, defining hours and optionally the minutes and seconds. In this way both 165503 or 16:55:03 are valid time representation for the same moment.**[hh]:[mm]**and**[hh]**are both valid time formats; - When combining date and time, concatenate both patterns with the letter “
**T**“, determining beggining of the time representation:**<date>T<time>**. Ex. 2019-10-12T12:15 means 12th October from 2019, exactly at Midday and 15 minutes. - About midnight: “2019-04-12T24:00” is the same instant as “2019-04-05T00:00”.
**Duration**(“*how long*“) is represented with the format P[n]Y[n]M[n]DT[n]H[n]M[n]S, where n is a number. The letters mean the representation of date and time:- P express that this is a
*period*format, and should be the first character; - Y for years; M for months; D for days;
- T is the delimiter for the time;
- H for hours; M for minutes; S for seconds;

- P express that this is a
- Date or time can be omitted, but always remember to use the
**P**delimiter in the beginning, and if using time, use the**T**delimiter necessarily. Ex. the duration of*two years and four months*, and three hours can be represented with: P2Y4MT3H; A duration of 4 hours and 20 minutes, by PT4H20m; “P3M” is a three-month duration and “PT3M” means three minutes duration; - The
**time intervals**can be represented with**/**delimiter, where we can have:- begin
**/**end. Ex. 2019-04/2019-06 to represent from April to June 2019; - begin
**/**duration. Ex. 2019-12-25T10:00:00/PT1H to represent the duration of one hour starting at 10 AM from Christmas day (25th Dec) in 2019. - duration
**/**end. Ex. the period that covers three months before 12th October: P3M/-10-12; - duration. Ex. two seconds period: PT2S;

- begin
- For repeating intervals, the delimiter
**R**is used**Rn/<interval>**, where n is the number of times the repetition should happen. Unlimited repetition is achieved by ommiting letter**n**. Examples:- Repeat two times, starting at 12th April 2019 Midday. R2/2019-04-12T12:00;
- Repeat an interval of 5 minutes, 5 times, before 01th Jan 2020: R5/PT5M/2020-01-01
- Repeat every 1 hour and 30 minutes: R/PT1H30M

## 2 thoughts on “ISO-8601 Time Standard”