| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Date formats

Page history last edited by Justin Spratt 11 years, 11 months ago

 

I have seen all of these dates in real life:

 

  • 01/03/06
  • 10-7-09
  • 11-11-2009
  • 12/10/09
  • Nov 14-16
  • 8.15
  • March 18
  • 12-03-17

 

I do not know what dates they refer to because all of the following formats are in use (in various, overlapping places around the world):

 

  • dd-mm-yyyy
  • yyyy-mm-dd
  • yyyy.d.m
  • yy/mm/dd
  • mm-dd-yyyy
  • mm/dd/yy
  • d/m/yy
  • d.m.yyyy
  • d-m-yyyy

 

Only the ISO 8601 date format is unambiguous.  There is only one format in use that begins with a four digit number and then a hyphen and then two digits and then two digits and then another hyphen and then two final digits.  2011-07-13 can only possibly refer to July 13, 2011.

 

The other advantage of using the ISO 8601 standard date format is that the lexicographical order of the representations is equivalent to the chronological order of the dates.  In other words, the dates sort in order of their date.  ISO Dates can be sorted using simple string comparison algorithms, and indeed by any left to right collation. For example:

 

  • 1998-02-28 (February 28, 1998) sorts before
  • 1999-03-01 (March 1, 1999) which sorts before
  • 2000-01-30 (January 30,  2000)

 

The YYYY MM DD layout is the only format that can provide this.

 

Different standards may need different levels of granularity in the date and time, so this profile defines six levels. Standards that reference this profile should specify one or more of these granularities. If a given standard allows more than one granularity, it should specify the meaning of the dates and times with reduced precision, for example, the result of comparing two dates with different precisions.

 

Other valid ISO formats are as follows. Exactly the components shown here must be present, with exactly this punctuation. Note that the "T" appears literally in the string, to indicate the beginning of the time element, as specified in ISO 8601.

   Year:
      YYYY (eg 1997)
   Year and month:
      YYYY-MM (eg 1997-07)
   Complete date:
      YYYY-MM-DD (eg 1997-07-16)
   Complete date plus hours and minutes:
      YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
   Complete date plus hours, minutes and seconds:
      YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
   Complete date plus hours, minutes, seconds and a decimal fraction of a
second
      YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)

where:

     YYYY = four-digit year
     MM   = two-digit month (01=January, etc.)
     DD   = two-digit day of month (01 through 31)
     hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
     mm   = two digits of minute (00 through 59)
     ss   = two digits of second (00 through 59)
     s    = one or more digits representing a decimal fraction of a second
     TZD  = time zone designator (Z or +hh:mm or -hh:mm)

 


Home  |  Up  |  Copyleft  |  Contact

Comments (0)

You don't have permission to comment on this page.