Angular2 data feed automatically adds timezone to date

I have a date string such as 1987-06-15T00:00:00.000Z , when I add a date on it, the date shows a different date, for example Jun 14, 1987 , in the US time zone, but in India it displays correctly.

 <div>{{'1987-06-15T00:00:00.000Z' | date}}</div> 
+5
source share
2 answers

This code works for me

 <div>{{date_of_birth.split("T")[0] | date}}</div> 
+1
source

The line 1987-06-15T00:00:00.000Z represents different dates in different time zones of the browser.

Fix

If you do not want to change the date based on the time zone, just use string parsing (e.g. substr ) and not date parsing.

+4
source

Source: https://habr.com/ru/post/1270705/


All Articles