Daylight saving time error (Summer time) in bootstrap-datepicker

Asked

Viewed 1,118 times

4

The plugin stopped working with the start of summer time in Brazil. When I disable the option on my machine (Automatically adjust to daylight saving time) the plugin comes back to work.

Code:

$('.campodata').datetimepicker({
    useSeconds: false,
    format: 'DD/MM/YYYY HH:MM'
});

Console error:

Erro no Console do chrome

  • 2

    Welcome to Stackoverflow in English, aka Sopt. I edited your question to remove the English part (we do not write in English to explain the problem), also withdrew your greeting, because as people read at different times it loses its meaning, our focus is always on questions and answers, it may seem rude of me, but it’s a convention we have here :)

  • Take a look here: https://github.com/eternicode/bootstrap-datepicker Have a link to an online demo, try to reproduce the problem you are having in your application, if it happens you can open an Issue.

  • Arthur, what version of the datepicker are you using?

  • Does it give any error? In my simply does not work, no error in the console....

1 answer

1

I had this problem recently. To fix it I edited an excerpt of the bootstrap-datepicker Fill method that used to be like this:

var prevMonth = new Date(year, month - 1, 28, 0, 0, 0, 0),
   day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());

And then it was like this:

var prevMonth = new Date(year, month - 1, 28, 12, 0, 0, 0),
   day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());

And the parseDate method, where it was:

date.setHours(0);

Became:

date.setHours(12);
  • 2

    Your footnote fits well in your "About me", which is said to pass is empty. The site usually avoids any kind of interference with publications, either in the question or in the answers. Here we usually avoid greetings, thanks and advertisements. If your link was vital to understanding the answer it would make sense to keep it, but the way it is is merely promotional and runs away from the scope of the site. Any doubt can consult the [meta].

Browser other questions tagged

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