Rabi Siddique
134 words
1 minutes
Date Object in Javascript

In JavaScript, the Date object represents a single moment in time in a platform-independent format. Date objects contain a number called a timestamp that represents milliseconds passed since the Unix Epoch on January 1, 1970, at 00:00:00 UTC.

const myDate = new Date('2023-22-11');
console.log(myDate.valueOf()); // Number of milliseconds till date from midnight 1st Jan 1970

Understanding the Date Object Output#

Consider the following timestamp: 2023-11-22T12:05:24.835Z. This output can be broken down into several components, each representing a different part of the date and time:

  • Year: 2023
  • Month: 11 (November)
  • Day: 22
  • Time: 12:05:24.835 (12 hours, 5 minutes, 24 seconds, and 835 milliseconds)
  • Time Zone: The Z at the end indicates Zulu time, also known as Coordinated Universal Time (UTC).

Further Reading#

Good Links about reading about Dates in JavaScript:

Date Object in Javascript
https://rabisiddique.com/posts/date-object-javascript/
Author
Rabi Siddique
Published at
2023-11-22