简体   繁体   中英

bootstrap datepicker start at a specific date

I would like to have bootstrap start at a specific date. Let say 01.05.1970. I have tried

startDate and endDate but they limit range. I would like that when the date picker is clicked it's started at that specific date.

This is the code that I currently have.

$('#NavCal').datepicker({
  //language: "<? echo strtolower(_("LANGUAGE_ALPHA_2"));?>", 
    todayHighlight: true,
    todayBtn: true,
    format: "yy-mm-dd",
    //startDate: new Date('2000-01-01'),
    //endDate: new Date('2030-01-01'),
}).on('changeDate', function (e) {
     a = e.format(0,"yyyy-mm-dd");
     ........
});

I also tried this

//defaultViewDate: new Date(1977, 1, 1),
    //defaultViewDate: {year:1977, month:01, day:28},
    //defaultViewDate: new Date('1977-01-01'),
    defaultViewDate: '1977, 1, 1',

But none seem to work...

Use the defaultViewDate option.

$('#NavCal').datepicker({
    format: 'yyyy-mm-dd',
    defaultViewDate: '2000-01-01'
});

You can see all the available options here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM