Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Invalid time value - formatInTimeZone() Timezone offset value returning error. How to use this function with offset? #274

Open
toduyemi opened this issue Apr 2, 2024 · 0 comments

Comments

@toduyemi
Copy link

toduyemi commented Apr 2, 2024

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?

@toduyemi toduyemi changed the title RangeError: Invalid time value- formatInTimeZone() Timezone offset value returning error. How to use this function with offset? RangeError: Invalid time value - formatInTimeZone() Timezone offset value returning error. How to use this function with offset? Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant