4 ms·
valueAsDate: ”The date returned should always be interpreted as a UTC time” The setHours trick will probably not work as expected if the user is on a timezone
by cluckindan 1y ago
valueAsDate: ”The date returned should always be interpreted as a UTC time”
The setHours trick will probably not work as expected if the user is on a timezone with a positive UTC offset.
They select a date in their local time, but in UTC, the date is still the previous day’s date!
So when user selects 2025-07-30 in +09:00, the UTC datetime will be set to 2025-07-29T15:00:00Z. setHours will then make it 2025-07-29T00:00:00Z, the date part of which would be rendered in local time as 2025-07-29, a full day off from what the user intended.
- sangeeth96 1y agoAh, dang it! Thanks! Now that I read it, even *-local ones won’t do what I thought they did? valueAsDate isn’t a thing there. Wish I could unvote myself or that comment. Note to self: never comment on HN when you’re groggy and on a phone and never trust Date APIs lol. Can’t wait for Temporal to get here which hopefully irons these out better.