I return from WEBapi a date like
2013-01-01T00:00:00
And I want
{{msa.StartDate | date:'yyyy-MM'}}
To be
2013-01
But because it wants to take my current time zone in consideration (US eastern) it is
2012-12
Is there a easy way to tell it DO NOT CARE ABOUT TIMEZONES? Or is there some other filter I can run the date through to ignore my time zone?
As it is described in documentation "If no timezone is specified in the string input, the time is considered to be in the local timezone." (http://docs.angularjs.org/api/ng.filter:date). So you can set time zone yourself. For example this will use UTC time zone
{{'2013-01-01T00:00:00' + 'Z' | date:'yyyy-MM-dd HH:mm'}}
Result (I'm on the West Coast and have 8 hours difference with London)
2012-12-31 16:00
As of at least Angular 1.4 you can use the date filter's "timezone" parameter to format the date for a given offset. In this case, to keep the time unchanged, use "UTC".
{{msa.StartDate | date:'yyyy-MM':'UTC'}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With