Base solution for your next web application
Open Closed

UTC Normalization from Repository not working #4240


User avatar
0
bertusvanzyl created

When I send a datetime from the frontend through an AppService, it gets converted to UTC. But when I get a datetime value from a repository, it is not converted back to local time, even though I have the time zone set correctly in the settings.

According to this doc here: <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Timing">https://aspnetboilerplate.com/Pages/Documents/Timing</a> It should convert when reding from the database as well.

Is there something I am required to set up in Zero for this to work properly?


5 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @BertusVanZyl ,

    Which version/type(angular or mvc) of product are you using?

  • User Avatar
    0
    bertusvanzyl created

    I am using angular 1, with MVC backend.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @BertusVanZyl,

    It is not converted to timezone when you get data from repository. If you are using UTC Clock Provider, you will get dates in UTC. You need to convert it to target timezone by yourself.

    If there is no need on server side convertion, we suggest to send UTC dates to client end convert to user's timezone in client using moment.

  • User Avatar
    0
    bertusvanzyl created

    Ok no problem. You guys might want to adjust the documentation here (<a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Timing">https://aspnetboilerplate.com/Pages/Documents/Timing</a>) a bit, it contains the following:

    ABP automatically normalized DateTimes received from database based on the current clock provider, when EntityFramework or NHibernate modules used.
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @BertusVanZyl,

    There is no timezone keyword in this sentence but you are right, it is a bit confusing even when I read it now :). We will try to make it better.