angularjs - Angular show wrong time with unknown timezone -


flight.departure_at utc format 2016-05-04t19:00:00.000z

when display expression in page,

it's format totally out of expectation.

why 12:00 come out? how come?

i want know how keep time format in utc globally without adding options everywhere. make whole app vulnerable

code

departure_time: {{flight.departure_at}} ||| {{flight.departure_at | date: 'hh:mm'}} 

output

departure_time: 2016-05-04t19:00:00.000z ||| 12:00 

this standard called iso-8601 , format is: yyyy-mm-ddthh:mm:ss.sssz

't' separator between date , time in iso-8601 format.

'z' 0 time zone ( getting 12:00 , because convert timezone)

we can use parse ,

var date = new date('2016-05-04t19:00:00.000z'); console.log(date.getutchours()); // hours - 19 console.log(date.getutcminutes()); //0 console.log(date.getutcseconds());// 0   console.log(date.parse(date)); console.log(new date(date.parse(date)));  

or

date.parse(date) getting time in standard time format

utc


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -