【发布时间】:2016-07-03 16:47:46
【问题描述】:
我在这里遗漏了一些关于日期的内容。
假设我有一个非常基本的输入页面,像这样
标记
<input type="date" ng-model="item.date">
<button ng-click="test(item)">Test</button>
角度模块
angular.module('test', []).controller('ctrl', function($scope, $http){
$scope.test = function(item) {
$http.post('___', item);
}
});
然后在服务器端有这个琐碎的代码。
date_default_timezone_set ( 'Europe/Rome' );
var_dump( new \DateTime($input['date']) );
作为 $input['date'] 发布后的 JSON 日期值,它包含一些 iso 格式,如下所示:
2016-03-22T23:00:00.000Z
现在,设置了时区,我希望上面提到的 ISO 日期可以用正确的时区正确处理,但我看到的是这个
object(DateTime)#1 (3) {
["date"]=>
string(26) "2016-03-22 23:00:00.000000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}
应该改为 2016-03-23 utc+1。
tl;dr
不应该是下面的代码
date_default_timezone_set ( 'Europe/Rome' );
var_dump( new \DateTime('2016-03-22T23:00:00.000Z');
解决为 2016-03-23 UTC+1 ?
【问题讨论】:
-
两天差?
标签: javascript php angularjs json timezone