Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to manage Clocks and TimeZones #5806


User avatar
0
josus created

Hi,

I read the docs about Timing but I don't know how it works. I want to have all DateTimes in Database in UTC. When a Backend User or API call is done, the dates will be in LocalTime and then, translated to UTC. Same behavior when a backend user o API call gets dates from the application. My first question is, what is LocalTime? then Tenant Setting for TimeZone or the user computer timezone? what about the API clients?

My ClockProvider is set to Utc, I have an API endpoint that creates records using Clock.Now. It is saved ok to Database with UTC value. But when I get these records the DateTimes fields are not translated to the Tenant TimeZone.


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

    Hi @josus

    When you are using UtcClockProvider, the dates will be UTC when you get them from database. So, you need to convert them to users or tenants timezone manually.

    If you want to show dates to user on the UI, you can use moment-timezone library which is included and used in AspNet Zero.

    If you want to use those dates on the server (generating an excel file for example), you can inject and use ITimeZoneConverter.

  • User Avatar
    0
    josus created

    Hi!

    I was thinking the automatic translation was done by using the Tenant TimeZone but I found that every user profile has his own TimeZone, default to Tenant TimeZone setting if the use don't change it. So, when I was trying to get translated datetimes, my user profile was set as UTC (the default Timezone when it was created!!!!)

    Now it works without any manual translation!!!

    Thanks.

  • User Avatar
    0
    josus created

    Hi!

    I was thinking the automatic translation was done by using the Tenant TimeZone but I found that every user profile has his own TimeZone, default to Tenant TimeZone setting if the use don't change it. So, when I was trying to get translated datetimes, my user profile was set as UTC (the default Timezone when it was created!!!!)

    Now it works without any manual translation!!!

    Thanks.