HighChart datetime json

Examples from HighCharts show that they expect dates to be formatted as Date.UTC(2014, 0, 1). Date.UTC actually returns milliseconds since 1 jan 1970. So you can send it as a number from your backend.

In C# you would use the following method:

/// <returns>Milliseconds since 1 jan 1970</returns>
public static long UnixTimestamp(this DateTime date)
{
return (long)(date – new DateTime(1970, 1, 1)).TotalMilliseconds;
}

One thought on “HighChart datetime json”

  1. I did that but I still can’t get this going.

    for (i = 0; i < data.length; i++){
    processed_json.push([data[i].key,data[i].value]);
    }

    data[i] at milliseconds but nothing happens.

    series: [{
    name: 'Monday',
    data: [processed_json]
    }]

Leave a Reply

Your email address will not be published. Required fields are marked *