Chartjs-Set xAxes labels to format YYYY-MM-DD HH:mm:ss in Chart.js

1👍

You can use property displayFormats according to Display Formats from Chart.js documentation. See Moment.js for the allowable format strings.

scales: {
  xAxes: [{
    type: 'time',
    time: {
      unit: 'second',
      displayFormats: {
        second: 'YYYY-MM-DD HH:mm:ss'
      }
    }
  }]
}

Leave a comment