[Chartjs]-Weird time formating with chart.js and moment.js

1๐Ÿ‘

โœ…

A JavaScript timestamp (see Date.now()) is in milliseconds, not seconds like a Unix timestamp.

To make moment.js recognise your timestamp you probably need to multiply it by a thousand (since Chart.js is passing your value to moment.js):

1535577869 * 1000

If you were creating a moment directly you could specify an input format:

moment(1535577869, 'X');

Leave a comment