dqwh1202 2015-11-10 10:44
浏览 121
已采纳

为什么angular $ http将datetime字符串转换为unix时间戳?

I have a PHP file which is retrieving value, id and time. Below is an example of the output of the PHP file when accessed directly:

//Using this 
$print($json_encode($data))

//Returns this
"data":[  
  {  
    "y":7.76,
    "x":"2015-05-04 01:23:37",
    "CoilId":"E5E001B11"
  }
]

Now when I use my factory method "getData" to retrieve the data and console log it, I end up with this:

"data":[  
  {  
    "y":7.76,
    "x":1444017905000,
    "CoilId":"E5E001B11"
  }
]

Here is my factory:

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 + "
" + "Status" + status + "
"+ "Headers"
                       + headers + "
" + "Config" + config + "
");
        });

        return promise;
    },

};

}]);
  • 写回答

1条回答 默认 最新

  • doqs8936 2015-11-10 12:27
    关注

    Bit of weird one here, but it turns out that this only seems to happen in chrome. This was a subset of a larger issue which has now been resolved. (It was to do with date formatting in different browsers, including phantomjs)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记