#46: Getting the Timestamp of a Date in the Past or Future
Now that you know how to get the current timestamp, let's explore how to determine some other timestamps close to the current time. For example, you can extract yesterday's timestamp or, say, next Friday's. There are two general methods for finding these values:
Determining the timestamp based on a string
Determining the timestamp from date values (which can be a bit trickier)
Creating Timestamps from a String
The strtotime()
function can sometimes be a PHP programmer's best friend. Just as its name suggests, strtotime()
generates a timestamp from an English date-phrase, such as April 1 or Friday. These strings can be either relative to the current date or absolute. Table 6-2 outlines some ...
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.