我有一个UTC日期,我将其传递给Angular的日期过滤器,以便在提交表单后将其转换为本地时区,并且仍然在如下所示的同一页面中:
$scope.XService.update($scope.Id, $scope.model).success(function (data, status, headers, config) {
$scope.addAlert("success", "Opération terminée avec succès");
var mydate1 = data.StartDateTimeUtc;
var mydate2 = data.EndDateTimeUtc;
data.StartDateTimeUtc = $filter('date')(new Date(mydate1), 'dd/MM/yyyy HH:mm');
data.EndDateTimeUtc = $filter('date')(new Date(mydate2), 'dd/MM/yyyy HH:mm');
$scope.model = data;
alert($scope.model.PublishStartDateTimeUtc);
alert($scope.model.PublishEndDateTimeUtc);
}).error(function (data, status, headers, config) {
$scope.addAlert("danger", data);
});
这项工作对我来说非常好,日期转换为当地时区但我的问题是这个转换代码对我不起作用 得到像贝洛一样的方法:
$scope.XService.get($scope.Id).success(function (data, status, headers, config) {
var mydate1 = $scope.model.StartDateTimeUtc;
var mydate2 = $scope.model.EndDateTimeUtc;
$scope.model.StartDateTimeUtc = $filter('date')(new Date(mydate1), 'dd/MM/yyyy HH:mm');
$scope.model.EndDateTimeUtc = $filter('date')(new Date(mydate2), 'dd/MM/yyyy HH:mm');
$scope.model = data;
alert($scope.model.EndDateTimeUtc); alert($scope.model.StartDateTimeUtc);
console.info("advertisning model", $scope.model);
$scope.model.Id = $scope.AdvertisementId;
$scope.newCreate = false;
}).error(function (data, status, headers, config) {
});
}
它返回BD中保存的UTC日期,可能是什么问题?