RangeError: Invalid time value - formatInTimeZone() Timezone offset value returning error. How to use this function with offset?
Opened this issue · 0 comments
In the documentation, the API states timezone offset is a valid parameter for the formatInTimeZone()
function.:
In this case there are two relevant pieces of information:
a fixed moment in time in the form of a timestamp, UTC or ISO date string, and
the time zone descriptor, usually an offset or IANA time zone name (e.g. America/New_York).
I have an API query that returns data related to:
- a timestamp in Unix, UTC (eg. 1712055855)
- a timezone offset in seconds (e.g -14400)
What I've tried:
formatInTimeZone(
1712055855,
`${-14400 * 1000}`,
'iiii',
);
There are no examples in the documentation showing a usecase of timezone offset.
I've tried converting the timeset time value to hours with the same result. I assume the unit of measurement is in milliseconds as the function getTimezoneOffset()
returns the offset in milliseconds.
What is the proper format for timezone offset? Why isn't the result of result of the utility function compatible with the main function?