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
<?php
// Get the current date
$today = date("Y-m-d");
echo "Today's date is: " . $today;
?>
xxxxxxxxxx
$datetime = DateTime::createFromFormat('YmdHi', '201308131830');
echo $datetime->format('D');
// or
$date = new \DateTime();
echo $date->format("D");
xxxxxxxxxx
<?php
$month = date('m');
if($month == 12){
echo "<br />December is the month :)";
} else {
echo "<br /> The month is probably not December";
}
?>