我正在使用datetimepicker.js
。
我有以下代码:
部分HTML:
<div ng-hide="editingData[x.date]">{{x.date|date}} </div>
所以我的约会对象是:
May 21, 2015 2:52:29 PM
预期:
May 21, 2015 2:52:29 PM IST
那么有没有简单的方法在angularjs
添加时区?
我也包含moment.js
,并发现它可以很好地操纵日期。它有用吗?
答案 0 :(得分:3)
显示本地时区
可能会对你有所帮助:)。
<div ng-app ng-controller="MyCtrl">
{{date | date:'MMM dd yyyy - h:mm:ss a '}} {{z}}
</div>
function MyCtrl($scope) {
$scope.date = new Date();
var now = new Date().toString();
$scope.z = now.indexOf('(') > -1 ?
now.match(/\([^\)]+\)/)[0].match(/[A-Z]/g).join('') :
now.match(/[A-Z]{3,4}/)[0];
if ($scope.z == "GMT" && /(GMT\W*\d{4})/.test(now)) {
$scope.z = RegExp.$1;}
}