Home forums Chart Support Displaying incorrect date time while converting epoch value

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #25294

    In xaxis i need to display the date time, as i am passing the epoch value, but it is displaying the old date of 1970.

    but if i am converting the epoch value to date time then it shows the exact value.

    >>> time.strftime(‘%Y-%m-%d %H:%M:%S’, time.localtime(1558743070))
    ‘2019-05-25 05:41:10’

    Where i am going wrong. Please help me.

    Below is my code:

    window.onload = function () {

    var chart = new CanvasJS.Chart(“chartContainer”,

    xValueType: “dateTime”,
    valueFormatString: “DD/MM/YYYY HH:mm”
    data: [
    type: “spline”,
    xValueType: “dateTime”,
    xValueFormatString:”DD/MM/YYYY HH:mm”,
    dataPoints: [




    Epoch timestamp is in seconds whereas JavaScript uses milliseconds as timestamp. Converting epoch timestamp to JS timestamp before passing it to chart, by multiplying epoch timestamp by 1000 should work fine in your case. Please refer this stackoverflow thread for more information.

    Vishwas R
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.