<?Php
echo date("m/d/y"); // Today's date in m/d/y format
echo "<br>"; // Line break
echo date("d/m/y : H:i:s"); // Date/month/year Hour Minutes Second
echo "<br>"; // Line break
echo date("F j, Y, g:i a"); // today's date with time
echo "<br>"; // Line break
echo date("F j, Y, g:i a",time()) // same as above
?>
PHP can generate today date and time in different formats.
Here is a simple date command in PHP to display today date.
date("date format",[timestamp])
Here is a sample output using m/d/y format: 10/06/24
echo date('M');
The output is here.
Oct
echo date('M',strtotime("first day of last month"));
Sep
echo date('M',strtotime("last day of -2 month"));
Aug
echo date('l');
The output is here.
Sunday
echo date('d');
The output is here.
06
echo date('U');
Output is here ( refresh this page and see the change )
1728187834
This is same as output of time() function. $tdtp=date("Y-m-d H:i:s",time());
Here is the output ( refresh this page and see the change ) 2024-10-06 04:10:34
Creating Date object by using date and time interval
Date as string by using strtotime()
PHP Date FunctionsDate formats for Date()
clyf | 29-03-2012 |
i want u to send me the scripts in php of how to recover a forgotten password, how to create a form with a photo attached to it, just reply to my email, thanx |
nobby | 10-06-2014 |
the article was helpfull but still the time i get on my page is one hour ahead any idea on how to reduce it so as i can get the appropriate time? thank you in advance |