I'm trying to integrate the jquery calendar plugin into my custom cms,
My issue is that events are shown the next day that the original value (in database) is set.
This is how i am retrieving my events:
$query = "SELECT id,avatar, titulo AS title,texto as name, unix_timestamp(start_date) as start,unix_timestamp(end_date) as end, start_date, end_date
FROM blogs
WHERE (unix_timestamp(start_date) >= '$start' OR unix_timestamp(end_date) <= '$end')
AND post_type = 'event'
AND lan = '$lan'";
//echo $query;
$year = date('Y');
$month = date('m');
$result = mysql_query($query);
$array = array();
$i = 0;
while ($row = mysql_fetch_array($result)) {
$raw = $row;
$raw['url'] = '/blog/'.urls_amigables($raw['title']).'/'.$raw['id'].'/';
$raw['start_show'] = prettyDateTime($raw['start_date']);
$raw['end_show'] = prettyDateTime($raw['end_date']);
$array[$i] = $raw;
$i++;
}
echo json_encode($array);
And this is how i am showing them into the jquery calendar:
$('#calendario').fullCalendar({
events: "/includes/json-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
eventMouseover: function( event, jsEvent, view ) {
var item = $(this);
var image = '';
if(event.avatar != '')
image = '<img src="'+event.avatar+'" />';
if(item.find('.nube').length == 0){
var info = '<span class="nube"><h2>'+event.title+'</h2>'+image+' <p class="text">'+event.name+'</p><p>'+event.start_show+' <br /> '+event.end_show+'</p><p><a href="'+event.url+'">read_more</a></p></span>';
item.append(info);
}
if(parseInt(item.css('top')) <= 200){
item.find('.nube').css({'top': 20,'bottom':'auto'});
item.parent().find('.fc-event').addClass('z0');
}
if(parseInt(item.css('left')) > 500){
item.find('.nube').css({'right': 0,'left':'auto'});
item.parent().find('.fc-event').addClass('z0');
}
item.find('.nube').stop(true,true).fadeIn();
console.log(parseInt(item.css('left')));
},
eventMouseout: function( event, jsEvent, view ) {
var item = $(this);
item.find('.nube').stop(true,true).fadeOut();
},
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventRender: function(event, element) {
}
});
The problem here is that unix_timestamp(start_date)
would generate the next day in the calendar
(ex: if is stored the start_date in day 17 of the month, in the calendar will appear in the day 18th)
and I'm not sure what i've missed. All this i made it by following their specs...
Any idea where am i failing? (jquery, mysql or timezone settings?)
-EDIT-
I kind of fixed it by
$row['start'] = $row['start'] - 60*60*24 /* One day */;
So now start_date
and start
make sense together (IN the calendar...)
Please tell me you know a better solution!