Formatting Dates
Dates can be formatted using the format() method of the DateTime class.
Example
Section titled “Example”$date = new DateTime();
echo $date->format("Y-m-d");echo $date->format("d/m/Y");Formatting with time
Section titled “Formatting with time”echo $date->format("Y-m-d H:i:s");