Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Parse An ISO Date In JavaScript

The native [TODO: Code shorthand span ] JavaScript object can parse ISO style date string. For example, this one without a timezone :

javascript
const dateString = '2021-11-12T02:03:03'
const dateObject = new Date(dateString)

That code will produce a date object that will print out this if logged :

2021-11-12T07:03:03.000Z

Note that the time has moved to Zulu (or GMT) time. That is, the hour shifted from 2 to 7.

Once the date is parsed, you use functions like :

javascript
.getFullYear()
.getMonth()
.getDate()

And all the other ones listed here

Note, this is done without using [TODO: Code shorthand span ] which is "strongly discouraged due to browser differences and inconsistencies." ( source