Simple Time and Date

PHP’s built-in date() function can take in certain predefined letters and display a variety of formats of the date and time. All of these can be seen in the PHP Manual at however a few of the most used formats are below:

print date("H:i T, jS F"); // prints 09:40 GMT, 1st September
print date("d-m-Y"); // prints 01-09-2003
print date("l, dS F Y"); // prints Monday, 1st September 2003

There are more fancier things you can do with a simple date, such as keep an up-to-date copyright notice on the footer of your web site (so when February comes and you still haven’t changed it from last year you can use PHP to do this automatically!), and there are more advanced functions available to you, however I’ll go into these a little more indepth later on.

You may also like...

2 Responses

  1. pest says:

    love the copyright idea… just using on a site now…

    i can’t wait to see it change date… in 11months time!

  2. Junaid says:

    Wow, this was posted nearly 7 years ago.