DateTime Class
The DateTime class provides an object-oriented interface for working with dates and times.
Creating a DateTime Object
Section titled “Creating a DateTime Object”$date = new DateTime();
echo $date->format("Y-m-d H:i:s");Creating from specific date
Section titled “Creating from specific date”$date = new DateTime("2025-01-01");
echo $date->format("Y-m-d");