Date And Time – PHP Fundamentals
In PHP to format a date or a time, ‘date( )’ operate is used. This operate makes time and date simple to learn. Generally used characters for dates : d, m, y, l (small L). Right here, ‘d’ represents day, ‘m’ represents month, ‘y’ represents 12 months and ‘l’ represents day of week.
And for added formatting characters comparable to :- [ “/”, “.”, or “-” ] can be utilized.
SIMPLE DATE FORMAT
1 |
<!DOCTYPE html> <html> <body><?php echo "In the present day is " . date("Y/m/d") . "<br />"; echo "In the present day is " . date("l"); ?></body> </html> |
Output :
Copyright 12 months (Auto)
1 |
<!DOCTYPE html> <html> <body>© 2010-<?php echo date("Y");?> Code-Tasks.org</body> </html> |
Output :
Regular Time
1 |
<!DOCTYPE html> <html> <body><?php echo "The time is " . date("h:i:sa"); ?></body> </html> |
Output :