PHP Tutorial
The PHP date() function is used to format a date and/or a time.
date(format,timestamp)
Here is the description for each parameters.
The required format parameter of the date() function specifies how to format the date (or time).
Here are some characters that are commonly used for dates:
<?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");
echo "Today is " . date("Y");
?>
It will produce the following result −
Today is 2020-05-28
Today is 2020/05/28
Today is 2020.05.28
Today is Thursday
Today is 2020
The PHP date() function is used to format a time.
Here are some characters that are commonly used
<?php
echo "The Time is " . date("h:i:sa") . "<br>";
echo "The Time is " . date("h") . "<br>";
echo "The Time is " . date("i") . "<br>";
echo "The Time is " . date("s"). "<br>";
echo "The Time is " . date("a");
?>
It will produce the following result −
The Time is 07:45:06am
The Time is 07
The Time is 45
The Time is 06
The Time is am