开发者

FullCalendar one hour ahead

I am using a JQuery plugin to render a calendar (http://arshaw.com/fullcalendar/). Problem is that the dates are one hour ahead. I have tried looking into the files to find out where this happens.

Can it be something with day light savings? I am pretty clueless. The dates from the database is correct, but once they are converted to a UNIX timestamp they are missing one hour.

I use this to convert my date to timestamp.

private double ConvertToTimestamp(DateTime value)
{
    //create Timespan by subtracting the value provided from
    //the Unix Epoch
    var date = new DateTime(1970, 1, 1, 0, 0, 0, 0);

    TimeSpan span = (value - date.ToLocalTime());

    //return the total seconds (which is a UNIX timestam开发者_高级运维p)
    return (double)span.TotalSeconds;
}

But i believe its not where the problems lies.

Thank you.


Is it possible that you live in a part of the world that observes Daylight Savings Time? That would explain why your dates are an hour ahead. Try skipping ahead to December and adding a few dates. Are they still an hour ahead?


I have had a similar problem and solved it with:

function _changeToLocal (localDate) {
      return new Date( localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), 
         localDate.getHours(), localDate.getMinutes() + localDate.getTimezoneOffset());
}

assuming it's a TimeZone related problem. Günter


I just experienced a similar issue when moving from my dev box to Amazon EC2 for staging... The Regional Settings on my Amazon instance were set to US West Coast, not my timezone (Sydney, Australia).

Changing this, and then updating the locales of the built in accounts (Network Instance etc) resolved my problems with the dates being rendered incorrectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜