开发者

Calculating relative time offset

开发者 https://www.devze.com 2023-01-19 18:10 出处:网络
I was reading this article about relative time calculation The problem is that the results are wrong due to the time offset. My webpage is Greek.

I was reading this article about relative time calculation

The problem is that the results are wrong due to the time offset. My webpage is Greek. So how should i modify that function to work correctly, including the GMT+2 or GMT+3 hours开发者_JS百科 offset?


I am Greek too, you only need to use the DateTime.Now, and not the DateTime.UtcNow

And by the way Greek is +2h


You shouldn't have a problem if you treat everything as UTC time. For example, instead of using DateTime.Now, use DateTime.UtcNow. Given that you are dealing with relative time, as long as everything is compared against the same base, you should be fine.

0

精彩评论

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