Serena Serena - 1 month ago 5
PHP Question

Need to change my date format

How can I change the format of my date from 2016-10-05 to 10/05/2016 in php

$date= $row['date'];


So when the row echos out it'll all be the new format

Answer

Use DateTime to create an object (from the current format), allowing you to reformat the output.

$date = "2016-10-05";
$date = DateTime::createFromFormat('Y-d-m', $date);
echo $date->format('d/m/Y'); 

https://repl.it/DqvO

Comments