arrow_back
Back

JavaScript dates and time: Date, Intl, and time zones

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

To work with time we use Date objects.

const date = new Date();
date.getFullYear();      // 1980
date.getMonth();         // 6
date.getDate();          // 31
date.getDay();           // 4
date.getHours();         // 0
date.getMinutes();       // 0
date.getSeconds();       // 0
date.getMilliseconds();  // 0
date.getTime();          // 333849600000 (for GMT)

Five days ago:

const date = new Date();
date.setDate(d.getDate() - 5);
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

JavaScript classes: syntax, OOP, and constructors

arrow_forward