Search code examples
phpdatepickerbootstrap-form-helper

bootstrap form helper date picker default


I am using Bootstrap form helper and want to update the record with new date in which user already selected date earlier. I cannot find the way to display date in date picker from database . Following is the code:

the date from db e.g

$date="1990-10-25"

      <div class="bfh-datepicker" id="dob" data-name="dob" data-min="01/01/1960" data-max="today" data-format="d/m/y"  ></div>

I have tried to add $date variable as placeholder= ”echo $date; ” also date=” echo $date; ”

cannot reach the solution. Need help support.


Solution

  • You are setting a data-format as d/m/y. So, you need to pass the date with the same format:

    <?php
    $date= "1990-10-25";
    $date = date('d/m/Y', strtotime($date));
    ?>
    
    <div class="bfh-datepicker" data-date="<?php echo $date; ?>" id="dob" data-name="dob" data-min="01/01/1960" data-max="today" data-format="d/m/y"></div>