Server time or time zone info is wrong
Server time or time zone info is wrong
22 May 2016, 19:30
The Spotware's cAlgo server's time information seems to be wrong or TimeZone.BaseUtcOffset does not reflect the correct offset.
var serverTime = new DateTimeOffset(Time, TimeZone.BaseUtcOffset); var utcNow = DateTimeOffset.UtcNow;
Print($"Server time: {Time:yyyy-MM-dd HH:mm:ss}"); Print($"Server UTC Offset: {TimeZone.BaseUtcOffset}"); Print($"Server time with UTC Offset: {serverTime:yyyy-MM-dd HH:mm:ss zzz}"); Print($"UTC Now: {utcNow:yyyy-MM-dd HH:mm:ss zzz}");
Output:
22/05/2016 19:01:57.202 | Server time: 2016-05-22 17:01:57 22/05/2016 19:01:57.202 | Server UTC Offset: 00:00:00 22/05/2016 19:01:57.202 | Server time with UTC Offset: 2016-05-22 17:01:57 +00:00 22/05/2016 19:01:57.202 | UTC Now: 2016-05-22 16:01:57 +00:00
If the server's time is correct then the offset values has to be +01:00. If the offset is correct then the time value is wrong.
I think the time is correct but the offset is wrong.
My time zone is +03:00 with daylight saving regime otherwise it is +02:00. London's time zone is 01:00 with daylight saving regime otherwise it's 00:00. I checked online and it's same with the server's time value but offset is +01:00.
So, the TimeZone.BaseUtcOffset value is wrong. Needs to be corrected.
Replies
moneybiz
23 May 2016, 10:35
RE:
tmc. said:
I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.
TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);
Doesn't this give your local time offset from UTC? It doesn't have anything to do with server's UTC offset.
@moneybiz
Jiri
23 May 2016, 11:15
RE: RE:
moneybiz said:
tmc. said:
I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.
TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);Doesn't this give your local time offset from UTC? It doesn't have anything to do with server's UTC offset.
Oh sorry, I misread your issue. Try the following.
Print(TimeZone.GetUtcOffset(Server.Time));
@Jiri
Jiri
23 May 2016, 00:38
I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.
@Jiri