Skip to content

Non-valid .toISOString(), must include 'Z' at the end #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
warmrobot opened this issue Mar 26, 2025 · 3 comments
Open

Non-valid .toISOString(), must include 'Z' at the end #50

warmrobot opened this issue Mar 26, 2025 · 3 comments

Comments

@warmrobot
Copy link

warmrobot commented Mar 26, 2025

https://github.com/date-fns/tz/blob/main/src/date/index.js#L29-L30

And there is no seconds, by the way

@GianlucaWassermeyer
Copy link

Hello,

The 'Z' indicates that the ISOString is in Zulu time (UTC). He uses the variant with the timezone offset inside the ISOString for TZDate, which is just as valid as the other format. Furthermore, JavaScript Date does not accept any timezone offsets with seconds; it would be an invalid ISOString.

@sovcik
Copy link

sovcik commented Apr 15, 2025

Well, as format is is valid to have both "Z" and "+00:00", but it differs from what Javascript toISOString should do:

  1. datetime is always UTC
  2. suffix is always "Z"
    see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

Image

I actually like TZDate approach more - never really understood why toISOString changes timezone too, but that's how it is... and if TZDate's goal is to be fully compatible, then this should be fixed.

@GianlucaWassermeyer
Copy link

GianlucaWassermeyer commented Apr 15, 2025

If you don´t like the toISOString() from TZDate, you can use TZDateMini as a workaround. That´s what I use in my project to always return an ISOString with Z.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants