Locale DateTime in ABP

前端 未结 1 927
忘了有多久
忘了有多久 2021-01-28 22:07

I have a DateTime field in popup modal as below that is supposed to only show the time part:

HTML:

相关标签:
1条回答
  • 2021-01-28 22:31

    I ended up with changing my formatDate method to following:

    formatDate(date: any, format: string): string {
        return moment.utc(date.toString()).local().format(format);
    }
    

    It show the local time when getting the value from DB, but now the issue is when updating its value. When I save the form it considers the date to a local time and everytime it deducts 10:30 from it and then send to the server!

    Here is the scenario:

    1. Assume this the UTC time saved in DB: 2018-02-23 00:00:00
    2. On populating the field it adds 10:30 (my local time zone) to it and shows it in the field: 2018-02-23 10:30:00
    3. I save the form without changing the above value
    4. The moment deducts 10:30 hours from the returned value from the server (2018-02-23 00:00:00) again and sends it to the server to be saved.
    5. Then I have a new value for the field without changing it in the form (2018-02-22 13:30:00)!
    0 讨论(0)
提交回复
热议问题