Angular 4 Date Pipe converting wrongly

前端 未结 4 1792
栀梦
栀梦 2020-12-09 17:14

I have rest service which returns a collection of objects and one of the field of the item is a date string (ISO-8601 format ) and the date value as follows

4条回答
  •  不思量自难忘°
    2020-12-09 17:41

    You may need to create a UTC date from your date with timezone... I assume you are in the pacific timezone as the time is 7 hours from UTC...

    Try this code to get a new date object without Timezone (assuming your variable is named "date"):

    var datewithouttimezone = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),  date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
    

提交回复
热议问题