Chapter 3. Date and TimeMost of the time, the date and time functionalities of PHP 5 are used for printing out the current date and timeto 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 datesdate(). 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 Time." To do so, you call date() and provide a string as the first parameter. This string may now contain a list of formatting symbols that can be seen in Table 3.1 (the PHP manual carries a list with more examples at http://php.net/date). Each of these symbols is replaced by the associated date/time value.
The function date() is very powerful and offers a broad range of ways to use it. However, especially if you have localized content, you need some good phrases. In this chapter, you will find many of them. PHP's date and time functions have their own section in the PHP manual. You can find more information about date() and friends at http://php.net/datetime. |