I have a date in my column that is varchar(30) and in my table it appears the format d/m/y I want to convert it to m/d/y
I try this but wont work. please help.
$test = new DateTime('date');
echo '<td>' .date_format($test, 'm-d-Y').$row.'</td>';
I have a date in my column that is varchar(30) and in my table it appears the format d/m/y I want to convert it to m/d/y
I try this but wont work. please help.
$test = new DateTime('date');
echo '<td>' .date_format($test, 'm-d-Y').$row.'</td>';
You can use DateTime::createFromFormat and DateTime::format:
$date = DateTime::createFromFormat('d/m/y', $row['date']);
echo $date->format('m/d/y');
you can use:
echo date("m-d-Y",strtotime($row['date']));
example:
echo date("m-d-Y",strtotime("8/7/2014"));
where $row['date'] is date fetched from db table.