0

In the below code i am using timezone of pacific/Auckland as per their timezone today date i.e.,11-April-2017 is completed now their date is 12-April-2017 but in my date picker 11th April is not disabled. I need to disable previous date i.e., is 11-April-2017.

This is my datepicker code

.datepicker({
               autoclose: true,
               todayHighlight: true,
               startDate: new Date().toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
             })
Arun Raju
  • 139
  • 2
  • 15
  • Possible duplicate of [jQuery Date Picker - disable past dates](http://stackoverflow.com/questions/8356358/jquery-date-picker-disable-past-dates) – Kody R. Apr 11 '17 at 14:46

3 Answers3

1

You can do this just by sustracting one day from today's date(new Date()) in startDate attribute.

Try this to substract one day from today's date in client side;

.datepicker({
           autoclose: true,
           todayHighlight: true,
           startDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
         })
KOUSIK MANDAL
  • 2,002
  • 1
  • 21
  • 46
1

The minDate option is what you are looking for.

.datepicker({
       autoclose: true,
       todayHighlight: true,
       minDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
 })
1

You will have to create it with minDate:

.datepicker({
       autoclose: true,
       todayHighlight: true,
       minDate: // whatever you choose,
       startDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
     })
Kody R.
  • 2,430
  • 5
  • 22
  • 42