With APIs like Intl, I can obtain the date and time of any Unix timestamp in any time zone. How can I do the reverse?
I’d like to be able to convert any particular triplet of <calendar-date>
(YYYY-MM-DD), <local-time>
(HH:MM:SS), and <time-zone>
(IANA timezone) (which do not necessarily correspond with fixed timezone offsets) to a Unix timestamp. I am not looking to just convert the current timestamp (which is trivial) or looking for solutions that presuppose I have a Javascript Date object; what we have is only the calendar date, local time, and time zone.
Solutions such as adding time zone offsets do not work reliably (eg in cases of DST). I had hoped Intl allowed for easy calculation of this problem.
2
Answers
Does this work for you?
It was not trivial
Does the Luxon version work for you?