Full Calendar does not respect end date

Asked

Viewed 505 times

0

I created an agenda with using Full Calendar, it displays the events, but does not respect the end date, always ends the event a day before, but only in the display. I don’t know if that field Duration is being respected, but should respect the field end. Below is the code that makes the search and mounts the json:

$conexao = new PDO('', '', '');
  if(!$conexao){
  echo "<script> window.location.replace('../erro.html'); </script>"; 
}

$consulta = $conexao->query("SELECT id, title, start, end, datediff(ADDDATE( end, INTERVAL 1 DAY), start) as duration FROM eventos");
    while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { 
        $vetor[] = $linha;        
     }
    //Passando vetor em forma de json
    echo json_encode($vetor);

Thanks if anyone has any suggestions how to solve.

js:

<script>
    $(document).ready(function() {  

            //CARREGA CALENDÁRIO E EVENTOS DO BANCO
            $('#calendario').fullCalendar({
                header: {
                    right: 'prev,next',
                    center: 'title',
                    left: 'month,agendaWeek,agendaDay'
                },
                //defaultDate: '2016-01-12',
                editable: true,
                eventLimit: true, 
                events: 'eventos.php',           
                eventColor: '#0277BD'
            }); 
    }); 

    </script> 
  • In json the returned data respects the end date?

  • Yes, the data is correct, but when displaying does not work, always ends a day before. The start date is ok, only so that it does not respect. I tried to use the field the field duration, but he also doesn’t respect.

  • In your select you cannot use the Between to pick up information between the two dates?

  • Is there any way you can put the js q snippet generates fullcalendar? If json is correct the error is in js.

  • Could you put the JSON that PHP generates so we can replicate your code?

1 answer

6


If you look at documentation will see that the last day (end) is EXCLUSIVE Which means the end day doesn’t count. For example if your event ends Monday, the end date should be Tuesday at 00:00.00 so that Monday is counted.

The END is the moment immediately after the event has ended.

  • Okay, I’ll try to add a day to the same date and not the duration time as it’s not working

  • Look seems to be a stopgap measure but it’s not, that’s how it works. I’ll even put a phrase of the documentation in the answer

  • I did as I mentioned, I added an extra day at the end date, it worked. Thanks for the tip!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.