开发者

startDate parameter value set at 3am insted of 12am

I'm trying out FullCalendar in an .NET MVC Application, and I'm having a problem with starDate and 开发者_C百科endDate parameters when fetching data.

I'm using Northwind database, Orders table, and setting the calendar to August 1996. Calendar displays from July, 28th (Sunday) to September, 7th (Saturday), but when fetching data, startDate is "838522800" which is "July, 28th 03:00 am". Since Orders at Northwind database do not store time (it's set to 12:00 am), orders for July 28th are not listed when displaying August calendar.

The function I'm using to convert Unix TimeStamp to C# Datetime was borrowed from here: http://codeclimber.net.nz/archive/2007/07/10/convert-a-unix-timestamp-to-a-.net-datetime.aspx

Why is Fullcalendar fetching data for startDate at 3am? How can it be solved?


Just found out what was happening... Javascript sends timestamp in UTC. The difference of 3 hs was due to Windows Time Zone (UTC-3) Fixed it by adding "ToLocalTime()" in C# function that converts Unix Timestamp to Datetime, so I changed this:

var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);

to this:

var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp).ToLocalTime();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜