Date And Time – PHP Basics

In PHP to format a date or a time, ‘date( )’ function is used. This function makes time and date easy to read. Commonly used characters for dates : d, m, y, l (small L). Here, ‘d’ represents day, ‘m’ represents month, ‘y’ represents year and ‘l’ represents day of week.
And for additional formatting characters such as :- [ “/”, “.”, or “-” ] can be used.

SIMPLE DATE FORMAT

<!DOCTYPE html>
 <html>
 <body>

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

</body>
 </html>

Output :

 

 

 

Copyright Year (Auto)

<!DOCTYPE html>
 <html>
 <body>

&copy; 2010-<?php echo date("Y");?> Code-Projects.org

</body>
 </html>

Output :

 

 

Normal Time

<!DOCTYPE html>
 <html>
 <body>

<?php
 echo "The time is " . date("h:i:sa");
 ?>

</body>
 </html>

Output :

 

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x