Reputation: 4886
I'm retrieving a datetime from a shared database. More precisely I'm retrieving a timespan and converting it to a datetime via Convert.ToDateTime(timespan.ToString())
. I have two servers which operate in two different time zones.
One returns the datetime as /Date(1402761600000)/
the other as /Date(1402776000000)/
, that's a difference of 14400000
, or 4 hours.
Just a hunch that this is somehow timezone related (as I'm at GMT -4).
Why are my times being returned differently? What can I do to prevent this?
Upvotes: 0
Views: 124
Reputation: 34810
Convert.ToDateTime
will return a local time which is why you are getting different results for servers in different time zones.
Try:
Convert.ToDateTime(ts.ToString()).ToUniversalTime();
Which will return the UTC time.
Upvotes: 1