iamkun / iamkun/dayjs

How to get a date in a specific timezone?

Open
#1,601 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Please reason the question in full before responding based on the arbitrary issue title.

A user enters a format such as this in a field `2021-08-08 8:00 PM`. I need to be able to create a date object of this exact time, in a different timezone of which the server uses. For my example, the server is located in Mountain Standard Time, and the date I need formatted is in Eastern time. No matter what I do, when i try to create a date, it always gives me a local time of 8pm in Mountain time, which is clearly not what I need, because that is a 3 hour offset.

This is what I've been testing with, and as you can see both examples the timezone still reads mountain time, leaving me no way to actually get the time of 8PM in eastern time, but instead either gives me my local converted time, or some other time i have no clue where its coming from. Ultimately the output I need to be able to print is a timestamp of the above exampled time in EASTERN time.
![image](https://user-images.githubusercontent.com/6024725/128647407-b4439eba-cfd6-4c82-8b9c-3cca692aa967.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.