1

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>

enter image description here

user433342
  • 859
  • 1
  • 7
  • 26

1 Answers1

0

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

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

Community
  • 1
  • 1
WhiteHat
  • 59,912
  • 7
  • 51
  • 133