Php 为什么$http要将日期时间字符串转换为unix时间戳?
我有一个PHP文件,它正在检索值、id和时间。下面是直接访问PHP文件时的输出示例:Php 为什么$http要将日期时间字符串转换为unix时间戳?,php,angularjs,Php,Angularjs,我有一个PHP文件,它正在检索值、id和时间。下面是直接访问PHP文件时的输出示例: //Using this $print($json_encode($data)) //Returns this "data":[ { "y":7.76, "x":"2015-05-04 01:23:37", "CoilId":"E5E001B11" } ] 现在,当我使用我的工厂方法“getData”检索数据并将其记录在控制台日志中时,我的结果是: "data":[
//Using this
$print($json_encode($data))
//Returns this
"data":[
{
"y":7.76,
"x":"2015-05-04 01:23:37",
"CoilId":"E5E001B11"
}
]
现在,当我使用我的工厂方法“getData”检索数据并将其记录在控制台日志中时,我的结果是:
"data":[
{
"y":7.76,
"x":1444017905000,
"CoilId":"E5E001B11"
}
]
这是我的工厂:
myApp.factory('Widget', ['$http', function($http) {
var promise;
return{
getData: function(widgetType, widgetId, machineId, start, end){
promise = $http({
url: "angular/data/testData.php",
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: $.param({widgetType: widgetType, widgetId: widgetId,
machineId: machineId, start: start, end: end })
})
.success(function(data, status, headers, config) {
console.log(data);
})
.error(function(data, status, headers, config) {
console.log("Data: " + data + "\n\r" + "Status" + status + "\n\r"+ "Headers"
+ headers + "\n\r" + "Config" + config + "\n\r");
});
return promise;
},
};
}]);
这里有点奇怪,但事实证明这似乎只发生在chrome上。 这是一个现已解决的更大问题的子集。 (这与不同浏览器中的日期格式有关,包括phantomjs)