xxxxxxxxxx
<?php
// Get the current date
$today = date("Y-m-d");
echo "Today's date is: " . $today;
?>
xxxxxxxxxx
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
xxxxxxxxxx
<?php
echo "Today's date is :";
$today = date("d/m/Y");
echo $today;
?>
xxxxxxxxxx
$currentDate = date('Y-m-d'); // Example date format: '2021-09-20'
echo $currentDate;
xxxxxxxxxx
date_default_timezone_set('Asia/Kolkata');
echo date("Y-m-d H:i:s"); // time in India
xxxxxxxxxx
# Current date
date_default_timezone_set('Asia/Kolkata');
echo date("Y-m-d H:i:s");
# Current Time
date_default_timezone_set("America/New_York");
echo "The time is " . date("h:i:sa");
xxxxxxxxxx
// Option 1: Using the date() function
$currentDate = date('Y-m-d');
echo $currentDate;
// Option 2: Using the DateTime object
$currentDate = new DateTime();
echo $currentDate->format('Y-m-d');