0

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

Serena
  • 45
  • 8

1 Answers1

0

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

ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49