locked
DateTime - Previous Day Issue for specific regions RRS feed

  • Question

  • User-1129879462 posted

    My SPA application is based out of Knockout as front end and ASP.Net Web API with EF as backend. Seems everything works fine until if someone changes submits date from India region. Though front end is correctly sending data to the web service, it seems on the server side previous day is taken only if users are submitting any dates from India region. This is not an issue with any other region like US Central. There is no explicit conversion method used. I am scratching head and wondering who/what is going on here. The field in question is declared as DateTime field. Any help would be much appreciated. 

    Thanks.

    Wednesday, November 11, 2020 2:02 PM

All replies

  • User1535942433 posted

    Hi krisrajz,

    As far as I think,you try to trust the client passing dates to the server as little as possible. For example, if you need "now", don't create a date on the client and then pass it to the server. Either create a date in your GET and pass it  or on POST do DateTime.UtcNow.

    Or,you could pass dates and timezone to the server.

    More details,you could refer to below article:

    https://stackoverflow.com/questions/7577389/how-to-elegantly-deal-with-timezones

    Best regards,

    Yijing Sun

    Thursday, November 12, 2020 6:08 AM