Home >>PHP Date Time Functions >PHP date() Fuction
PHP date() function is used to format the local timestamp into a more readable date and time format and returns the formatted date string.
Syntax;
date(format, timestamp);
Parameter | Description |
---|---|
format | This is a required parameter. This parameter defines the format of the outputted date string. |
timestamp | This is a n optional parameter. This parameter defines an integer Unix timestamp. |
Here is an example of date() function in PHP;
<html> <body> <?php echo date("d-m-Y")."<br>"; echo date("j-n-Y")."<br>"; echo date("d-M-Y")."<br>"; echo date("d-M-Y (D)")."<br>"; echo date("jS-M-Y (l)")."<br>"; ?> </body> </html>
Example 2:
<html> <body> <?php echo date("d-m-Y",-706320000)."<br>"; echo date("j-n-y",-706320000)."<br>"; echo date("d-M-Y",-706320000)."<br>"; echo date("d-M-Y (D)",-706320000)."<br>"; echo date("jS-M-Y (l)",-706320000)."<br>"; echo date("jS-F-Y (l)",-706320000)."<br>"; ?> </body> </html>