Table of Contents

  1. Timezones
  2. ISO 8061 format
  3. Date Constructions

Hi there πŸ‘‹, i see that many developers are facing with problems about Date in javascript recently. Today, I gonna to show you how to use Date in js correctly.

Timezones

There are 2 definitions about timezones in js: UTC and Local time zones Local time refers to the timezone your computer is in.
UTC is synonymous with Greenwich Mean Time (GMT) in practice.

ISO 8061 format

What is it? It’s an international standard introduced by ISO in 1988. Acctually, it describes the way to write date, time easily that our computers can understand it.

Date constructions

Syntax

  new Date()
  new Date(value)
  new Date(dateString)
  new Date(dateObject)

  new Date(year, monthIndex)
  new Date(year, monthIndex, day)
  new Date(year, monthIndex, day, hours)
  new Date(year, monthIndex, day, hours, minutes)
  new Date(year, monthIndex, day, hours, minutes, seconds)
  new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds)