Chapter 6. WORKING WITH DATES

WORKING WITH DATES

This chapter shows you how to work with dates and times with PHP. Web programs often involve an extensive amount of extraction, manipulation, comparison, and display of dates. The task gets more involved when you add MySQL to the mix. But first, let's talk about the native time format on your server.

How Unix Time Works

Before going into detail about how to work magic with dates, I have to get into the basics of how POSIX-compliant Unix/Linux servers (and thus, PHP) keep time. Fortunately, it's a fairly simple system.

Midnight, January 1, 1970, is when time "began" for Unix computers. In Unix parlance, that timestamp ...

Get Wicked Cool PHP 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.