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 had the same question and couldn't find a solution in the docs. @date-fns Is there a reason there isn't a function like this?
/** returns a TZDate using the timezone of the ISO 8601 string */exportconstparseWithTz=(iso: string)=>{constoffset=iso.match(/([-+])(\d{2}):(\d{2})$/)?.at(0);returnnewTZDate(iso,offset);};letexample="2024-01-12T01:10:10.110-06:00";console.log(parseWithTz(example).toISOString());// 2024-01-12T01:10:10.110-06:00 ✅ identicalconsole.log(newTZDate(example).toISOString())// ❌ drops/loses original offset and outputs local/sys offset
From an external service, I receive time strings in the iso format, containing the timezone offset:
date-fns
parseIso correctly process the timezone, but converts the Date into the browser timezone.Is there a way to obtain a proper TZDate instance from such an isoString?
In the documentation I can only see ways to build a TZDate when you already know the desidered timezone in advance
The text was updated successfully, but these errors were encountered: