You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I have the same use case. I know the offset value of the timezone (in ms, fwiw), but don't have a time zone name. So i just would want to pass that offset as number to utcToZonedTime.
I was having a similar issue and had a look at the documentation.
For a specific hour/mins offset, you need to provide an offset value in the form of [+-]HH or [+-]HHMM, like this:
// PLUS 4 hour offset
const localDate = datefns.utcToZonedTime(new Date(), '+04');
// MINUS 2 hour 30 mins offset
const localDate = datefns.utcToZonedTime(new Date(), '-0230');
@psmod2 If you're using getTimezoneOffset(), it will return an offset in minutes, so you'd need to divide by 60 to get number of hours needed, and then convert to a string which is in the format similar to the example above
Hi,
I'm unable to use an offset in the utcToZonedTime().
It works fine with a IANA string like
America/Lima
- just when I do:The text was updated successfully, but these errors were encountered: