| Issue 1615: | Event is displayed on wrong month of calendar (month+1). | |
| 1 person starred this issue and may be notified of changes. | Back to list |
When printing out an event it ends up on the month after the one entered. So an event for November 25 ends up on December 25 instead.
I'm using PHP to print out the values from a database into the object:
<script type="text/javascript">
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: [
{
<? foreach( $events as $k => $v): ?>
title: "<?=$v->title ?>",
start: new Date(<?=$v->start_year ?>,<?=$v->start_month ?>,<?=$v->start_day ?>),
end: new Date(<?=$v->end_year ?>,<?=$v->end_month ?>,<?=$v->end_day ?>),
allDay: <?=$v->all_day == 1 ? 'true' : 'false' ?>,
<? if( strlen($v->id)>0 ): ?>
id: <?=$v->id?>,
<? endif; ?>
url: "<?=$v->url?>"
<? endforeach; ?>
}
]
});
});
</script>
<div id='calendar'></div>
Jan 17, 2013
#1
migue...@gmail.com
Jan 17, 2013
I think the "new Date" object expects a 0-11 month instead of a 1-12 month coming from PHP . According to w3schools.com (about Javascript date object, getMonth() function : Definition and Usage The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time. Note: January is 0, February is 1, and so on. It doesnt says it explicitly, but I beleive this is extensive to "new Date" and how it works.
Mar 19, 2013
Duh! I've been trying to work out what I've been doing wrong for ages, but now it all becomes clear.... Cheers!
Aug 18, 2013
(No comment was entered for this change.)
Status:
Done
|
|
| ► Sign in to add a comment |