I am getting the date from the database and populating it in the textbox.
In my database, the date is stored in the following manner - yyyy-mm-dd
Default date stored in the database is - 0000-00-00
<?php
if($result['dob'] == '0000-00-00'){
$dob = date('d/m/Y');
echo '<input class="form-control" name="dob" value="'.$dob.'" id="datepicker" type="text">';
} else{
$dob = date_create($result['dob']);
$dob = addslashes(date_format($dob, "d/m/Y"));
echo '<input class="form-control" name="dob" value="'.$dob.'" id="datepicker" type="text">';
}
?>
When I try to populate the date in my datepicker it shows the date to me in this manner - 01/01/-0000
I wonder why is it printing the -0000. Please help.
You can try writing $dob = date("d/m/Y",strtotime($result['dob']));
This will output your date from the database in the format of d/m/Y.