Calculating relative time offset
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.
精彩评论