开发者

Unbiased Time System C#

开发者 https://www.devze.com 2023-04-12 20:44 出处:网络
I am creating a reminder system for the software that we have.Currently I have the user give me the time they would like to be reminded and I store it in a database.

I am creating a reminder system for the software that we have. Currently I have the user give me the time they would like to be reminded and I store it in a database.

Then later, I have a service that periodically checks the database for reminder times. If the reminder time matches the server time, the system sends an email to the user.

I just now realized that this may not work because of time zone differences.

My question, what is the best way to handle time differences in the server and the client, so that the reminder is accurate?

For example..... our server is set for central time at say 6:00pm...... The user who is on the east coast wants a reminder at 7:00pm... this m开发者_开发知识库eans my server would need to send the reminder at 6:00pm server time.

I hope the question is clear.


I suggest handling everything in UTC internally, and having the client software do the region-specific translation. Then you can support any arbitrary time zone, and if you ever have to move the server elsewhere or your service gets popular enough to be multihomed, you are still OK.


Store everything in universal time and update your clients based off that conversion.

So simply put, instead of having your clients send you a request for 6:00 EST, have them first calculate the conversion between EST and UTC and send you the UTC instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号