CHAPTER 5Working with Dates and Times

Dates and times are quite unlike most other sorts of data you are likely to encounter when programming with PHP 5. Arrays, whether they are indexed arrays or associative arrays, are nicely structured. So are strings. Numbers are—well, they are numbers, and despite a few bumps here and there because of issues such as rounding, you are still obliged to work with a fairly limited set of mathematical operations and formatting functions. However, dates are rather messy with respect to both calculation and representation, and one is about as bad as the other.

Quick question: what were the date and time exactly 101 hours, 44 minutes, and 15 seconds prior to 7:35 p.m. on September 17, 1989? And what day of the week ...

Get PHP 5 Recipes: A Problem-Solution Approach 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.