Hi,
We're using 5.6.0 of AspNetZero and we've noted a few issues with the way dates are handled.
When a Date comes in from the ASP.NET side of things, it comes in as a non UTC time, eg:
"startDate":"2018-10-02T00:00:00"
Within Angular, it refers to the moment being the local Time Zone of British Summer Time and displaying quite correctly. When we submit back to ASP, the service-proxy does a stringify and converts to a UTC time zone "startDate":"2018-10-01T23:00:00.000Z"
This then causes a problem because when we get the date back again into Angular, it is being treated as, eg in this instance, 1st October 2018 at 11pm British Summer Time.
So if we keep doing a submit and refresh, the time will just keep going back by an hour.
What can we do to resolve this?
Regards, Simon Dean
10 Answer(s)
-
0
Convert to UTC time zone before submitting to ASP.NET Zero server.
-
0
how to convert to UTC time zone before submitting to ASP.NET Zero server?
-
0
Thanks for this. However as you can see, the service proxy does actually seem to convert to UTC time zone before submitting to the ASP.NET Zero server.
The problem appears to be in getting the time back from the ASP.NET Zero in that is it bringing in a time that is not denoted as being UTC and is therefore being treated as the local time zone.
So we submit eg 9pm BST, this gets sent and saved to ASP.NET Zero as 8pm UTC. When we get the time back, we get 8pm BST, and if we resubmit that time back to ASP.NET Zero, it gets saved as 7pm UTC. And the cycle continues. 7pm UTC > 7pm BST > 6pm UTC > 6pm BST etc etc
I'll have a look at those links to see if there's anything that might help with this.
Regards, Simon Dean
-
0
Hi @sddev
Are you using ClockProviders.Utc ? You can check how ABP handles times here https://aspnetboilerplate.com/Pages/Documents/Timing#clock.
-
0
Sorry for the delay in replying.
That article doesn't go too much into detail about where to set ClockProvider, but I have added this into the Startup.cs of the application, and this now seems to be passing back UTC Times correctly from ASP to Angular.
The Angular App (Service Proxies etc) is seeing the Z in the JSON showing that it is a UTC Time. So we're getting eg, 11pm UTC, but then just converting to a Moment of 11pm BST which is incorrect.
Regards, Simon Dean
-
0
https://momentjs.com/docs/
-
0
Could you run "abp.timing.timeZoneInfo.iana.timeZoneId" on the browser console and share it's value ?
-
0
Hi,
The timezone is reported as Etc/UTC.
And bizarrely, I can now see a Timezone option under "My Settings" which wasn't there before.
What should we set for the United Kingdom - bearing in mind we alternate between GMT (Greenwich Mean Time) and BST (British Summer Time)?
Bearing in mind if we put a time in of say, 9pm British Summer Time, which gets converted to 8pm UTC in the backend, we still want to see 9pm during BST and also during GMT.
Regards, Simon Dean
-
0
Hi @sddev
If you are seeing this setting, then the Clock.Provider is set correctly. I'm not sure what to select for TimeZone in your case. AspNet Zero only supports one timezone setting.
But, whatever you select, if the dates are stored in database as UTC, then you can convert them back to user's timezone on the clietn side using moment tiemzone library.
As far as I know, moment-timezone library handles timezone changes like GMT and BST.
-
0
Please reopen if you are still having this problem