Serena Serena - 1 year ago 64
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 Source

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');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download