0

I have a dateTime stored in my db as

2014-10-29 19:44:22

I am trying to set min date of DatePicker

Here is the code in php.

$creationDate =  $record['creationDate'];
                    $timestamp = strtotime($creationDate);
                    $year  =  date("y", $timestamp);
                    $month =  date("m", $timestamp);
                    $day   =  date("d", $timestamp);

Later in jquery

 $( "#calendar" ).datepicker({ minDate: new Date(<?php echo $year . "," .$month . "," .$day  . ",1"?>)});

result not working any fix?

2
  • What's the format in datepicker? Commented Oct 31, 2014 at 11:11
  • * @syntax new Date() new Date(milliseconds) new Date(dateString) new Date(year, month, day [, hour, minute, second, millisecond ]) Commented Oct 31, 2014 at 11:14

2 Answers 2

1

Just try.

$( "#calendar" ).datepicker({
     minDate: new Date(<?php
         echo date('Y, m, d',strtotime($yourDateVar));
     ?>)
});
Sign up to request clarification or add additional context in comments.

Comments

0

Try

     $("#calendar").datepicker({
            dateFormat: 'yy-mm-dd',
            minDate: '<?php echo date("Y-m-d",strtotime($creationDate)); ?>',
        });

change both format dateFormat: 'yy-mm-dd', and date('Y-m-d') according to your need.

For example if datepicker showing :- 2020/03/26 then

dateFormat: 'yy/mm/dd',
minDate: '<?php echo date("Y/m/d",strtotime($creationDate)); ?>',

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.