简体   繁体   中英

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 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM