[Chartjs]-Chart x axis displays in timestamp instead of dates Chart.js

1👍

You have to change the display format. chart.js likes unix, people like date strings.
You should add something like this function to display your dates:

function getTimeString(date) {
  var day = date.getDate();
  var month = date.getMonth() + 1;
  var year = date.getFullYear();

  return day + '/' + month + '/' + year;
}

Whenever I work with a time-scale in chart.js I add moment.js because it’s much more powerful. But it can be kind of an overkill for webapps.

Leave a comment