-1

The below code displays date in yyyy-mm-dd

 <td>
<?php 
echo($data['Date']);?></td> 
  <td>

I want it in mm-dd-yyyy

User
  • 29
  • 1
  • 8
  • 4
    possible duplicate of [Convert date in format MM/DD/YYYY to MySQL date](http://stackoverflow.com/questions/19459119/convert-date-in-format-mm-dd-yyyy-to-mysql-date) – Saty Jul 06 '15 at 05:43
  • 1
    possible duplicate of [Convert date format yyyy-mm-dd => dd-mm-yyyy](http://stackoverflow.com/questions/2487921/convert-date-format-yyyy-mm-dd-dd-mm-yyyy) – Narendrasingh Sisodia Jul 06 '15 at 05:47

3 Answers3

0
$originalDate = "2010-03-21"; 
$newDate = date("m-d-Y", strtotime($originalDate));
Bivin
  • 106
  • 1
  • 8
0
$s_date = $_POST['your_date_field'] // your date variable in  '2015-10-10 ' formate
echo date('m-d-Y',strtotime($s_date)) // return 10-10-2015
Affan
  • 1,132
  • 7
  • 16
0

Try this

Use strtotime($data['Date']) to convert string to date time

and the use date('m-d-Y',strtotime($data['Date'])) to format it to your requirement

<td>
<?php echo date('m-d-Y',strtotime($data['Date']));?>
</td>
Dinuka Dayarathna
  • 169
  • 1
  • 3
  • 9