问题描述
我从返回的WebAPI的日期像
I return from WEBapi a date like
2013-01-01T00:00:00
2013-01-01T00:00:00
和我想
{{msa.StartDate | date:'yyyy-MM'}}
为
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?
推荐答案
由于它在文档中描述如果字符串输入没有指定时区,时间被认为是在本地时区。 ( http://docs.angularjs.org/api/ng.filter:date)。所以,你可以自己设置时区。例如,这将使用UTC时区
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'|日期:'YYYY-MM-DD HH:MM'}}
结果(我是在西海岸,并与伦敦8小时差)
Result (I'm on the West Coast and have 8 hours difference with London)
2012-12-31 16:00
这篇关于怎样才能让不应用时区AngularJS仅仅打印的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!