Question

I am trying to implement jQuery.Gantt ( http://taitems.github.io/jQuery.Gantt/ ) into a site I am working on. I'm running into a weird issue with the Date objects. For testing purposes, I created "Milestones" January - December, each one having a start date of THAT month - 16th - 2012. Each one has the same end date of todays date, June 3rd, 2013.

Each of the start dates are displaying one day late( MONTH - 17, 2012). The end dates get weird: January, February, November and December all end at the correct point in the timeline, June 3, 2013. The eight months sandwiched in between all end a day late on June 4th, 2013.

I've been over the specifications for my date objects and my function is building them in the correct format:

_getDatesforMilestone = function(milestone){
    var testData = [];
    var toDate = milestone.completeDate.split("-");
    var fromDate = milestone.originalDate.split("-");

    toDate = new Date(toDate[0], toDate[1]-1, toDate[2]);
    fromDate = new Date(fromDate[0], fromDate[1]-1, fromDate[2]);

    testData = [
        {"from": "/Date(" + fromDate.getTime() + ")/", "to": "/Date(" + toDate.getTime() + ")/", "desc": "", "label": milestone.title, "customClass": "ganttDefault " + milestone.id + ""}  
    ];

    return testData
},

Has anyone else run into this issue, or know why the 8 months in between would be coming back like this? Thoughts instantly came to mind of the 30/31 days in the months or even last year was a leap year, but I'm coming up blank at this point.

Was it helpful?

Solution

This might be a bit late, but it might come in useful for anyone else looking for solutions to this issue.

Namely, I have just experienced a similar issue (dates displayed as one day earlier) and after a bit of fiddling around I've realized it has to do with the local time zone.

Basically, as I am currently in Russia, the local time zone is GMT+4, so if my DateTime field has a value of mm/dd/yyyy 03:59:00 AM the date will be displayed one day earlier. However, as soon as I set the date to mm/dd/yyyy 04:00:00 AM the date is displayed correctly on the timeline.

As I am not going to be the person entering dates into the system, and as I find this "feature" to be correct and quite useful, I will not fiddle with the handling of the dates, but in the user manual I will ask the entry person to always enter the times in GMT format, and this should prevent any issues.

I hope this helps!

Best regards

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top