Skip to main content

JavaScript Dates

6 lessonsAbout 36 minutesAdvanced

This part of the JavaScript Tutorial runs from JavaScript Dates through to JavaScript Date Pitfalls. There are 6 lessons here, and working through them takes about 36 minutes at a steady pace.

It follows on from JavaScript Map & Set, so finish that first if you have not already — the examples below assume you are comfortable with it.

Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.

  1. 1JavaScript DatesThe Date object represents a single moment in time.
  2. 2JavaScript Date FormattingtoLocaleDateString formats a date the way a reader in a given place expects.
  3. 3JavaScript Date ArithmeticDates can be compared and subtracted because they are numbers underneath.
  4. 4JavaScript Date ComponentsGetters read each part of a date, and setters change them.
  5. 5JavaScript TimestampsA timestamp is the number of milliseconds since the start of 1970.
  6. 6JavaScript Date PitfallsA few date behaviours catch out almost every JavaScript developer.