Polar B. February 2016

Date picker with custom start date

I am working on a form, for a web application. I have been researching on customizing a date picker plugin. I want to use a JavaScript/php date picker. But the issue is that the user can only choose date from a particular number. For instance: Today is 02/08/2016, the user can only be allowed to choose a date from 10/08/2016. Any date before the 10/08/2016 cannot be selected. How can i use php to control such functionality? Or is there any better way i can achieve this?

Answers


djl February 2016

I don't know if you are looking for this but it is a very simple to use.

HMTL

<!-- Enter a date after 2016-10-08 (you can make this variable with some php code): -->

<input type="date" name="bday" min="2016-10-08">

With PHP eg.

<input type="date" name="bday" min="<?php echo date('Y-m-d', (time() + 86400)); ?>">

86400 is one day in seconds.


See also W3Schools.


Ajay Makwana February 2016

try this:

$('#datepicker').datepicker({
    startDate: new Date()
});


Plum February 2016

Check Out this link for bootstrap calendar:- http://eternicode.github.io/bootstrap-datepicker/.
You will all the necessary methods to populate dates in your calendar.

<input type="text" class="form-control">
    $('#sandbox-container input').datepicker({
        format: "dd-mm-yyyy",
        startDate: "-1d",
        endDate: "+5d",
        autoclose: true,
        todayHighlight: true
    });

Post Status

Asked in February 2016
Viewed 3,371 times
Voted 7
Answered 3 times

Search




Leave an answer