-1

Need to change the date format to mm-dd-yyyy while fetching from database in some forms it is displaying in the same format in some files it is displaying in yyyy-mm-dd format.

While doing echo in the function it is displaying in the format ( yyyy-mm-dd)

<?php echo $oppointArr['dob'];?>

But while fetching the same data in input type date it is displaying correctly.

<input type="date" class="form-control" value="<?php echo $oppointArr['dob'];?>" name="dob" id="dob" >
  • _“But while fetching the same data in input type date it is displaying correctly.”_ - the keyword here is _display_. What your script output at this position, is still yyyy-mm-dd format - simply because a date input field _requires_ that format when setting a value. – CBroe Jan 12 '21 at 13:14

1 Answers1

0

you can use the date function of the PHP

https://www.php.net/manual/en/function.date.php

date('mm-dd-yyyy',strtotime($oppointArr['dob'])
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
M. Rashid
  • 16
  • 5