这就是我将 .Net Datetime 转换为 Javascript 的方式。我很久以前在某个地方找到了代码并将其用于 Highcharts。现在图表有时看起来很奇怪,线条混乱。我怀疑这与日期有关。
Datetime curDate = "11/14/2013";
string jsDate = "Date.UTC(" + curDate.Year + "," + (curDate.Month - 1) + "," + curDate.Day;
if (curDate.Millisecond > 0)
{
jsDate += "," + curDate.Hour + "," + curDate.Minute + "," + curDate.Second + "," + curDate.Millisecond;
return jsDate += ")";
}
if (curDate.Second > 0)
{
jsDate += "," + curDate.Hour + "," + curDate.Minute + "," + curDate.Second;
return jsDate += ")";
}
if (curDate.Minute > 0)
{
jsDate += "," + curDate.Hour + "," + curDate.Minute;
return jsDate += ")";
}
if (curDate.Hour > 0)
{
jsDate += "," + curDate.Hour;
return jsDate += ")";
}
jsDate += ")";
这是将.Net日期转换为javascript的正确方法吗?
谢谢!