Google Charts Table显示错误的日期 [英] Google Charts Table displaying incorrect date

查看:63
本文介绍了Google Charts Table显示错误的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此示例中 google图表表格的日期为16/1/16,并显示12/31/15.我需要使用某种时区还是其他方式?

In this example google charts table is given a date of 1/1/16 and displays 12/31/15. Do I need to use some kind of timezone or something?

<div id="chart"></div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:['corechart', 'table']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('date', 'dt'); 
  data.addRows([[new Date("2016-01-01")]]);
  var view = new google.visualization.DataView(data);
  var table = new google.visualization.Table(document.getElementById('chart'));
  table.draw(data);
}
</script>

推荐答案

与google-visualization无关,真正的答案在这里...
为什么Date.parse给出不正确的结果?

not related to google-visualization, the real answer is here...
Why does Date.parse give incorrect results?

使用诸如'01/01/2016'之类的格式来获得预期的结果...

use format such as '01/01/2016' to get expected results...

这篇关于Google Charts Table显示错误的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆