views:

22

answers:

2

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 offset?

A: 

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.

Mark Avenius
A: 

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

And by the way Greek is +2h

Aristos
The hosting server resides In U.K. Isn't that a problem?
Chocol8
@strakastroukas This is depend from what the server have set as the local time. If you have rent it from Greek provider then its probably have set the +2h so there is no problem.
Aristos
@strakastroukas The .Now its get the time using the system correction, the UtcNow its getting the time with out that correction. You can use ether UtcNow+2, ether Now and let get the +2 from the system setup.
Aristos
Brilliant! Thank you.
Chocol8