Monday, 29 May 2017 06:57

PHP Date Function

Syntax

date(format,timestamp)

Commonly used characters for date

d - The day of the month (01 to 31)

m - Month (01 to 12)

Y - Year in digits usually 4 digits (e.g 1988)

 l  - (small letter L ) - Day of the week

 

Example

<?php echo "Current date is " . date("Y/m/d") . "<br>"; echo "Current date is " . date("Y.m.d") . "<br>";
echo "Current date is " . date("Y-m-d") . "<br>";
echo "Current day is " . date("l");
?>


Result
 
Current date is 2017/05/29
Current date is 2017.05.29
Current date is 2017-05-29
Current day is Monday
 

Note: This will display the current date e.g output may not be the current date

Last modified on Monday, 29 May 2017 07:51

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.