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

Time Zone not Working #11833


User avatar
0
ricardo created

Hi,

I'm using mvc version 13.0.

datetime fields are not being converted to the time zone defined in host settings.

added in PreInitialize for CoreModule: Clock.Provider = ClockProviders.Utc;

the values are correctly saved in UTC in the database, but when retrieved in a query and displayed in HTML they continue to show in UTC

the converted value should be 12/01/2024 09:02:24


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

    Hi @ricardo

    Do you use MVC UI or Angular UI ?

  • User Avatar
    0
    ricardo created

    I'm using mvc (Asp.Net Zero version 13.0)

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ricardo

    For MVC side, only tables are automatically handled. If you are showing this date in a cshtml file, you will get the UTC value and you need to convert it to user's timezone using ITimeZoneConverter and then display it.

  • User Avatar
    0
    ricardo created

    Hi @ismcagdas,

    Thanks for the feedback.

    1. And in the service layer, the date will always be returned in UTC when received from the database? Or should it be converted to the logged in user's time zone?

    2. I'm using a DevExpress grid, how could I do this date conversion?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    1. Yes, it will be retrieved as UTC from database.
    2. In that case, you can use a custom render funciton (I guess DevExpress grid supports it) and then use https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Resources/Abp/Framework/scripts/abp.js#L905 to convert date to current user's timezone.