I have the following code:
console.log(
new Date().toISOString()
)
This returns: 2021-10-14T08:28:28.467Z
In my opinion it should return: 2021-10-14T08:28:28.000Z. The difference is the 000Z. In all examples (documentation) I see that it returns 000Z. In my case it doesn't.
How to make sure I also get the 000Z?
If you set the date yourself, you do get the 0s default if not you get the hh,mm,ss,sss the time has at the time the statement executes –
You have to set the milliseconds if you want 000
Not sure why you would expect 000Z
const d = new Date()
d.setMilliseconds(0)
console.log(d.toISOString())