amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.01k forks source link

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

Open carolineberlemont opened 5 years ago

carolineberlemont commented 5 years ago

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

DanielRuf commented 5 years ago

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)
carolineberlemont commented 5 years ago

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="pickerday pickerday--infocus pickerday--today pickerday--disabled" data-pick="1548111600000" role="gridcell" aria-label="22 Janvier, 2019" aria-disabled="true">22

DanielRuf commented 5 years ago

Can you share a codepen with us?

carolineberlemont commented 5 years ago

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!

DanielRuf commented 5 years ago

So does the provided solution work for you?