How to change date format in PHP

In this tutorial we will learn how to chnage the date format in PHP.
In this tutorial we will use strtotime() and date() funtion.
The strtotime() funtion used to convert an English textual date-time description to a UNIX timestamp.We can return the English textual date-time in date format using the date() function.

Change dd/mm/yyyy to yyyy-mm-dd

<?php
$originale_date = "18/09/2019";
$date = str_replace('/', '-', $originale_date );
$new_Date = date("Y-m-d", strtotime($date));
echo $new_Date;
?>
Output

2019-09-18

Change yyyy-mm-dd to dd-mm-yyyy

<?php
$originale_date = "2019-09-18";
$new_Date = date("d-m-Y", strtotime($originale_date));
echo $new_Date;
?>
Output

18-09-2019

Change yyyy-mm-dd to mm-dd-yyyy

<?php
$originale_date = "2019-09-18";
$new_Date = date("m-d-Y", strtotime($originale_date));
echo $new_Date;
?>
Output

09-18-2019