Name

strtotime

Synopsis

int strtotime(string time[, int timestamp])

Converts an English description of a time and date into a Unix timestamp value. Optionally, a timestamp can be given that the function uses as the “now” value; if this value is omitted, the current date and time is used. Returns false if the value could not be converted into a valid timestamp.

The descriptive string can be in a number of formats. For example, all of the following will work:

echo strtotime("now");
echo strtotime("+1 week");
echo strtotime("-1 week 2 days 4 seconds");
echo strtotime("2 January 1972");

Get Programming PHP, 3rd Edition 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.