Hi, I have a simple dto input with public int Id {get;set;} public DateTime StartDate {get;set;}
In my angular2 client app I use moment to populate the StartDate with moment(); In server side if the method is Get the date in converted to server time (as you do in GetAuditLogs), but if method si Post the date is parsed as is without consider the time zone and so I have different values.
How Can I use correctly moment and server side datetime management ? I don't need timezone.
Thank you.
5 Answer(s)
-
0
Hi,
ABP normalizes datetimes according to your Clock.Provider, do you use UtcClockProvider ?
But anyway, if you are sending same values in GET and POST, server must receive same values. Can you share the values send to server for GET and POST ?
Thanks.
-
0
I don't use UtcClockProvider. My goal is simply to write and read data exactly how client sent to server by an angular2 app.
<a class="postlink" href="http://.../api/services/app/api/getvalues?id=1&StartDate=2017-04-17T22%3A00%3A00.000Z">http://.../api/services/app/api/getvalu ... %3A00.000Z</a> If method receive the dto by querystring, startdate is correctly parsed in 2017-04-18 00:00:00 (Italian time zone) If method receive the dto by post, startdate is the same as input, 2017-04-17 22:00:00.
We are planning to move from local to azure server and we are investigating how deal correctly with date and time.
Thanks
-
0
Hi,
If this is related to ABP, you can set your Clock.Provider to UnspecifiedClockProvider. In that way, ABP will not change your datetime values at all.
Can you also check what is the value of Clock.Provider before changing it. Please let us know if it does not work.
Thanks.
-
0
I try to explain better because I don't know if is an ABP related behaviour. The scenario is very simple: ABP Clock provider is Unspecified as default. My application doesn't manage any timezone because is used only in the same region. The client is Angular2 and there are 2 methods on application service: one GET and one POST. The DTO is the same with two fields: Id (int) and StartDate (DateTime). Supposed that 'new Date()' is Thu Apr 20 2017 08:52:50 GMT+0200 (ora legale Europa occidentale), the StartDate sent over internet is "2017-04-20T06:52:50.324Z" serialized by JSON.stringify(). On the server side the GET method deserialize correctly in 2017-04-20 08:52:50, while the POST method deserialize in 2017-04-20 06:52:50. It seems the the ISO format is threated differently.
So, the question is: which is the correct way to deserialize the client dates? There is some example explanatory? Thanks Ivano
-
0
Hi,
I have tried your use case and it is working like you explained. Setting Clock.Provider to ClockProviders.Local seems to be fixing it.
Thanks.