我想將UTC日期和時間字符串轉換爲圖表上x軸的當前時間。我很確定我沒有正確使用Date.parse。任何幫助表示讚賞。謝謝。如何將字符串轉換爲javascript日期對象?
$.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);
}
你能告訴我們'結果[I] [「日期」]'的內容,並沒有任何錯誤消息? –
你沒有把'parse()'結果賦值給任何東西。 – acdcjunior
@acdcjunior我認爲這是問題,但我似乎無法得到正確的語法分配它,我是新來的JavaScript – evann