Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

javascript - Displaying Correct Time When In DST Or Not

I'm storing a schedule start time UTC, with the following information, Start hour, start minute and the day it is to trigger on. The issue I'm having is if I set a start time for 9AM, then I want 9AM to be shown all year, but I've noticed if DST comes into effect this isn't the case and I might see 8AM. Using Javascript, is there anyway I could ensure the correct time is shown regardless of DST? Would I need to store more information other than what I have mentioned above, to do this?

I've been playing around with the getTimezoneOffset() which returns the difference in minutes between local time and UTC, to see if I can offset correctly but having no luck, so wondering what is a recommeded implementation for this kind of scenario. I think Outlook stores the time zone along with it's scheduled time, so I'm thinking is that what I need to do.

question from:https://stackoverflow.com/questions/65922902/displaying-correct-time-when-in-dst-or-not

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...