有没有更好的方法来忽略Angularjs中的时区:
“2014-01-18 14:30:00”而不是“2014-01-18 15:30:00”
function Scoper($scope) { $scope.datum = "2014-01-18T14:30:00Z"; } <div ng:app ng:controller="Scoper"> DateTime <br /> Angular: {{datum | date:'yyyy-MM-dd HH:mm:ss'}} <br /> </div>
我找到了这个答案:
Why does angular date filter adding 2 to hour?
原文链接:https://www.f2er.com/angularjs/143680.html这是example:
管道另一个过滤器:
app.filter('utc',function(){ return function(val){ var date = new Date(val); return new Date(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes(),date.getUTCSeconds()); }; });
在您的模板中:
<span>{{ date | utc | date:'yyyy-MM-dd HH:mm:ss' }}</span>