PHPize Online / SQLize Online  /  SQLtest Online

Share      Blog   Popular


Tags: PHP 5.x PHP 7.x PHP 8.x

strtotime — Parse about any English textual datetime description into a Unix timestamp.


    string $datetime, 
    int|null $baseTimestamp = null
): int|false
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in baseTimestamp, or the current time if baseTimestamp is not supplied.

Warning: The Unix timestamp that this function returns does not contain information about time zones. In order to do calculations with date/time information, you should use the more capable DateTimeImmutable.

Each parameter of this function uses the default time zone unless a time zone is specified in that parameter. Be careful not to use different time zones in each parameter unless that is intended. See date_default_timezone_get() on the various ways to define the default time zone


A date/time string. Valid formats are explained in Date and Time Formats.
The timestamp which is used as a base for the calculation of relative dates.

Return Values

Returns a timestamp on success, false otherwise.

strtotime - New snippets