javascript - FullCalendar timezones not modifying times on client's end -


i experiencing frustrating issue i've been working on night. long story short, if in new york creates event @ 2pm, i'd event show 8pm viewing calendar in europe (they 6 hours ahead let's say).

my fullcalendar configs this:

  function renderschedule(timezone) {      var userschedule = $('#user-schedule').fullcalendar({              header: {                  left: 'prev,next today',                  center: 'title',                  right: 'month,agendaweek,agendaday'              },              timezone: timezone,              ignoretimezone: false,              events: baseurl + "load_schedule",              editable: true,              defaultview: 'agendaweek',              firsthour: 8,              alldaydefault: false          } 

i have more options, should suffice purpose of question.as mentioned in docs, fullcalendar passes url via looks this:

         mysite.com / my_page / load_schedule ? start = 2014 - 02 - 02 & end = 2014 - 02 - 09 & timezone = europe % 2fchisinau & _ = 1391660233815  

then, on backend doing following convert frommysql datetime toiso8601

$start = ($event['start']);  $end = ($event['end']);  $datestart = new datetime($start, new datetimezone($timezone));  $dateend = new datetime($end, new datetimezone($timezone));  $datestart - > settimezone(new datetimezone($timezone));  $dateend - > settimezone(new datetimezone($timezone));  $event['start'] = $datestart - > format(datetime::iso8601);  $event['end'] = $dateend - > format(datetime::iso8601);  $newresult[] = $event; 

the $timezone variable holds europe/chisinau of course passed fullcalendar itself.

here above returns fullcalendar:

[{"id":"5","start":"2014-02-06t14:10:00+0200","end":"2014-02-06t15:00:00+0200","title":"my title"}] 

everything seems correct, regardless of i've tried events show 2pm.

note important, haven't mentioned yet passing in timezone of choice renderschedule function. so, though located on east coast of us, able pass in european timezone , have calendar render accordingly.

also, should point out i'm using beta version (2.0) allows timezone string passed (which doing) , uses moments via moment.js

any idea i'm doing wrong here?

i able work demo. updated date format include colons offset. latest stable version of fullcalendar 1.6.4 doesn't have timezone variable.

$('#calendar').fullcalendar({         editable: true,         header : {             left:"prev,next",             center:"title",             right:"month,basicweek,agendaweek,basicday,agendaday"             },         ignoretimezone: false,         events: [         {             start: "2014-02-06t14:10:00+02:00",             end:"2014-02-06t15:00:00+02:00",             title:"my title",             allday: false         } }); 

if using beta release 2.0, need remove ignoretimezone no longer parameter.

updated answer:

it turns out issue how dates being handled on backend. here how solved problem.

date_default_timezone_set($timezone);             $timestampstart = strtotime($mysql_start_date);             $timestampend = strtotime($mysql_end_date);             $local_time_start = $timestampstart + date('z');             $local_time_end = $timestampend + date('z');             $local_date_start = date('y-m-d h:i:s', $local_time_start);             $local_date_end = date('y-m-d h:i:s', $local_time_end);              $event['start'] = $local_date_start;             $event['end'] = $local_date_end; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -