eva*_*ann 2 javascript ajax jquery
我想将UTC日期和时间字符串转换为图表上x轴的当前时间.我很确定我没有正确使用Date.parse.任何帮助表示赞赏.谢谢.
$.ajax({
url: "/chart/ajax_get_chart", // the URL of the controller action method
dataType: "json",
type: "GET",
success: function (result) {
var result = JSON.parse(result);
series = [];
for (var i = 0; i < result.length; i++) {
date = Date.parse(result[i]['date']);
tempArray = [parseFloat(result[i]['price'])];
series.push(tempArray);
series.push(date);
}
Run Code Online (Sandbox Code Playgroud)
Date.parse(result[i]['date']);
Run Code Online (Sandbox Code Playgroud)
您只是将日期解析为返回值,然后完全忽略结果.
你需要对返回值做一些事情.
此外,Date.parse()返回UNIX时间戳.
要创建Date实例,请致电new Date(str)
| 归档时间: |
|
| 查看次数: |
116 次 |
| 最近记录: |