我想将以下日期和时间转换为UTC格式
"1970-05-11T18:30:00.000+0000"
我可以在视图中执行此操作,但我想在控制器中执行此操作。
{{stmt.tranDate | date:"dd/MM/yyyy": 'UTC'}}
$scope.kycinfo.dob = "1970-05-11T18:30:00.000+0000";
$scope.dob = $filter('date')($scope.kycinfo.dob, "dd/MM/yyyy");
<input type="text" id="dateOfBirth" placeholder="Please Select ..." data-ng-model="dob" name="dob" ng-required="true" mobi-date=true />
答案 0 :(得分:4)
将“UTC”作为第三个参数传递给$ filter('date)。
$scope.kycinfo.dob = "1970-05-11T18:30:00.000+0000";
$scope.dob = $filter('date')($scope.kycinfo.dob, "dd/MM/yyyy", "UTC");
答案 1 :(得分:0)
我认为您可以尝试以下代码:
var toUTCDate = function(date){
var _utc = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
return _utc;
};