Skip to content

Instantly share code, notes, and snippets.

@Jonalogy
Last active October 20, 2018 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonalogy/48c253eca193f83f2593659a9dda805c to your computer and use it in GitHub Desktop.
Save Jonalogy/48c253eca193f83f2593659a9dda805c to your computer and use it in GitHub Desktop.
A Quick Reference To Common Date & Time Formats In Web Development

Common Date & Time Formats

ISO8601 Date Format

Syntax: YYYY-MM-DDTHH:MM:SSZ+HH:MM eg:2018-10-19T03:00:00.000Z

This consists 4 parts:

  1. YYYY-MM-DD: Standard Gregorian calendar date
  2. T: Date-time delimiter, it seperates the date from the time
  3. HH:MM:SS:SSS: Standard time representation in 24hr format. Seconds SS and milliseconds SSS may be ommited for brevity
  4. Z: Represents UTC Timezone with zero offset. (Fun fact: UTC stands for Coordinated universal time)
  5. +HH:MM: Which comes after the Z is the offset for UTC. Omitting this means 0 offset.

Try Natty if you still need help visualising, it has a parser for ISO8601 dates.

RFC2822 Date Format

eg. Mon, 21 Mar 2011 00:18:56 +0000

See more at IETF-compliant RFC 2822


Supplementary Informationals

  • JavaScript date

    • Evaluates using the client's clock as time reference, based on time value in milliseconds since midnight 1 January 1970 00:00:00 UTC.

        Date.now() //->1511232956323
        new Date(1511232956323) //->Tue Nov 21 2017 10:55:56 GMT+0800 (+08)
    • ECMAScript defines a dateString interchange format for date-times based upon:

      1. A simplification of the ISO 8601 Extended Format
        new Date('1995-12-17T03:24:00') //->Sun Dec 17 1995 03:24:00 GMT+0800 (+08)
      1. IETF-compliant RFC 2822 timestamps
        new Date('30 October 1930') //->Thu Oct 30 1930 00:00:00 GMT+0800 (+08)
  • There is no time difference between GMT and UTC

  • Coordinated Universal Time (UTC)

    UTC is a standard, NOT a time zone. A standard to represent date and time in 24 hours format and used globally as a basis for their own civil time / timezones.

  • Greenwich Mean Time (GMT)

    A time zone, officially used in some European and African countries. Can be represented in 24/12 hr formats.

  • Unix Epoch == Unix TimeStamp == POSIX Time

    It represents the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for 'Unix time'.

  • Locale

    Quoting from wiki: "In computing, a locale is a set of parameters that defines the user's language, region and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language identifier and a region identifier."

    Read more about it on this blog

Sources:

  1. MDN JavaScript Date
  2. What's The Best Date Format
  3. Wiki ISO 8601
  4. IETF-compliant RFC 2822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment