pickadate.js icon indicating copy to clipboard operation
pickadate.js copied to clipboard

how select the first day (min) of my calendar at today ?

Open carolineberlemont opened this issue 6 years ago • 5 comments

I would like the minimum date of my calendar to be today (and not tomorrow). What should I write for "min"?

carolineberlemont avatar Jan 22 '19 13:01 carolineberlemont

Hi @carolineberlemont,

basically by setting the date using Date.now() (current seconds since 01.01.1970) or by setting the date to the beginning of the day.

https://codepen.io/DanielRuf/pen/zeYmpv

$('.datepicker').pickadate({
  min: Date.now()
})
var curDate = new Date();
new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate(), 0)
// Tue Jan 22 2019 00:00:00 GMT+0100 (Mitteleuropäische Normalzeit)

DanielRuf avatar Jan 22 '19 14:01 DanielRuf

Thank you very much Daniel !

Unfortunelly, even with : min: Date.now(), the datepicker is disabled for today If I inspect the datpicker, I have this code :

div class="picker__day picker__day--infocus picker__day--today picker__day--disabled" data-pick="1548111600000" role="gridcell" aria-label="22 Janvier, 2019" aria-disabled="true">22

carolineberlemont avatar Jan 22 '19 22:01 carolineberlemont

Can you share a codepen with us?

DanielRuf avatar Jan 22 '19 23:01 DanielRuf

Ho yes, it's OK ! Thank you very much. It's only because I tried yesterday evening after 11pm and with the time différence, it's like we were already today. thank you!

carolineberlemont avatar Jan 23 '19 07:01 carolineberlemont

So does the provided solution work for you?

DanielRuf avatar Jan 23 '19 08:01 DanielRuf