Chapter 3. Date and Time

Most of the time, the date and time functionalities of PHP 5 are used for printing out the current date and time—to pretend that the web page is up to date (you would be surprised how many larger websites actually use this). But apart from that, working with date and time in PHP offers many other possibilities, most of which you will find in this chapter.

First, though, it seems appropriate to have a look at the PHP function that is probably used the most for working with dates—date(). This function can take the current date (or an arbitrary one) and extract some information about it, for example, the day, whether it's a.m. or p.m., and what time it is according to the rather failed marketing stunt, “Swatch Internet ...

Get PHP Phrasebook: Essential Code and Commands now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.