Locale DateTime in ABP

淺唱寂寞╮ 提交于 2019-12-02 09:01:35

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)!
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!