0

If I do the following:

const thisApril = new Date("2019-04-01T00:00:00")
console.log(thisApril.toISODate())

The output is 2019-03-31T23:00:00.000Z because .toISOString converts the date from UTC to my time zone. I just want to print the Date as ISO without any time zone conversions.

Frayt
  • 1,194
  • 2
  • 17
  • 38
  • 4
    Your `new Date(...)` parameter doesn't have a timezone, so it's converting *from* your timezone *to* UTC. Try `new Date("2019-04-01T00:00:00Z");` – Niet the Dark Absol Jun 04 '19 at 17:28
  • @NiettheDarkAbsol Thanks – Frayt Jun 04 '19 at 17:37
  • "Without any conversions" is not possible, because JavaScript's `Date` object is UTC-based internally. You are parsing a string that will be recognized as local time, but the `Date` object doesn't retain that. If you want to create a string in local time, you'll have to do that yourself (see the dup link - strip the offset if you don't want it). Or you can parse as UTC as Niet suggested if the value is indeed UTC based. – Matt Johnson-Pint Jun 04 '19 at 18:07

0 Answers0