How to Convert date format in PHP


Use strtotime() and date():

<?php
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
echo $newDate;
?>

On the above example I am using strtotime() and date() function to Convert date format in PHP.

Note: The original date format should be in minus format. If it is like 2010/03/21 then the above code will not work.