Issue 1615: Event is displayed on wrong month of calendar (month+1).
Status:  Done
Owner: ----
Closed:  Aug 2013
Reported by dan.cott...@gmail.com, Nov 20, 2012
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
You could try parsing out all your dates as this form : '2013-01-18' instead of javascript 'new Date(2013,1,18)'  


That did it for me


Jan 17, 2013
#2 migue...@gmail.com
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
#3 hiretheb...@gmail.com
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
Project Member #4 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Done