Setting xAxis Min and Max to Datetime

Mar 24, 2012 at 8:09 PM
Edited Mar 24, 2012 at 8:10 PM

Hi Everyone,

How can I set the Min and Max on the xAxis to a datetime? I've been able to do this in Javascript by just setting it to a Datetime object. I've tried something similar in DotNet Highcharts, but the graph it produces has a very large xAxis. The code I'm using is:

Min = new DateTime(2012, 3, 20, 13, 45, 00).ToUniversalTime()

I see that Min is a number, and I have tried all the possible number conversions for DateTime with no luck. Thanks in advance.

Mar 30, 2012 at 9:48 AM

Use this method:

public double GetTotalMilliseconds(DateTime dateTime)
            DateTime d1 = new DateTime(1970, 1, 1);
            DateTime d2 = dateTime.ToUniversalTime();
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);

            return ts.TotalMilliseconds;

Let as know whether it works for you. I'll include it into the next release of the library.


Mar 30, 2012 at 2:37 PM

Hi Vangi - that works great - cheers! I now realise that I was setting it with the wrong Epoch as it was an issue I was finding elsewhere in my code. 

Apr 1, 2012 at 10:13 PM

With release 1.2, you can use the method from: 


Marked as answer by Vangi on 10/24/2013 at 2:57 AM