I want to take an input string like '2024-08-24T20:00:00-04:00' (8pm in Boston MA), feed it to dayjs so that it will be formatted as the exact same time.
The time format I'm using is dayjs(startTimeStr).format('YYYY-MM-DD H:mm'), which is giving me '2024-08-25 1:00' but the actual format isn't important. What's important is that I want it to parse it without changing timezones.
I'm in Boston but I've set my computer's time zone to London. This is to simulate the behavior of my deployed Remix server, which appears to be on GMT, since when I use my actual time zone I can't reproduce the production bug locally.
I've tried using dayjs.tz but it simply results in 0:00 instead of 1:00. I'm guessing the difference of only one hour has to do with daylight savings time.
dayjs.extend(timezone)
// ...
const startTimeStr = '2024-08-24T20:00:00-04:00'
const id = dayjs.tz(startTimeStr, 'America/New_York').format('YYYY-MM-DD H:mm') // '2024-08-25 1:00'
What I want is simply for supply a date and time as a string, and get a dayjs object that is simply that time, with no Time Zone awareness, not even any Daylight Savings awareness!
In other words, parsing a string from format X to a date and back to format X should yield the exact original string, regardless of whether I'm parsing in June or January, regardless of whether I'm parsing in Boston or London.
Why is this so hard!?!?!?