<?php
// Get today's date
$date = date("Y-m-d");
// Print the date in various formats
echo "Today's date is $date<br>";
echo "Formatted date (1): " . date("l, F jS Y") . "<br>";
echo "Formatted date (2): " . date("F j, Y") . "<br>";
echo "Formatted date (3): " . date("m/d/Y") . "<br>";
echo "Formatted date (4): " . date("d-m-Y") . "<br>";
?>
Today's date is 2023-05-01
Formatted date (1): Sunday, May 1st 2023
Formatted date (2): May 1, 2023
Formatted date (3): 05/01/2023
Formatted date (4): 01-05-2023
date()
` function and stores it in the `$date
` variable. It then prints out the date in various formats using different format strings with the `date()
` function.