I have the html form which enter data into mysql DB, but in input field of date it has this format,
(mm/dd/yyyy)
BUT I prefer to use this form
<script id="template" type="text/x-handlebars-template"> <table> <tr> <th>Posted on: </th> <td>
<?php $date = '{{posted}}';</td> </tr> </table> </script> echo date('d M Y',strtotime($date));?>
use this code
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
You should be storing your dates as actual dates and not strings. You're only making your life more difficult by storing them in a non-standard format.
But if you insist on using this format, this code will work for you:
$original = DateTime::createFromFormat('m/d/Y', '04/18/1973');
$date = $original->format('d/m/Y');