Base solution for your next web application
Open Closed

TimeZone problem #1781


User avatar
0
andmattia created

Hi

I've an application that user can make a reservation and a lot of logic based on datetime, so in client side the user set a datepicker with 9:00 AM and I set my time zone in UTC +1, when data came from client to server in server side i see time set to 7:00 am and this value will be stored in database.

How is the best approch? Save on database in converted format or save in UTC?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It's better to store all dates in UTC in this case. But if you are using UtcClockProvider as Clock.Provider, the value on the server side should be converted to UTC, you don't have to do anything.

    If you are using moment timezone library (<a class="postlink" href="http://momentjs.com/timezone/">http://momentjs.com/timezone/</a>), it handles client side timezone operations. Even if you set timezone to UTC+1, because of the Daylight Saving Time, the selected date might be in UTC+2 timezone.

    For example in Turkey we are in UTC+2 timezone but in summer time we move to UTC+3 and now we are in UTC+3. So I think 7:00 AM you are getting on server is probably the UTC date.

    If this is not clear for you, please send the name of UTC+1 timezone you are setting on your app, then we can take a look at your case more deeply.