Home > PHP > Function > Date/Time > strtotime()

strtotime()

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

Syntax

int strtotime (string $time, int $now)

Arguments

  • time - The string to parse. Before PHP 5.0.0, microseconds weren\'t allowed in the time, since PHP 5.0.0 they are allowed but ignored.
  • now - The timestamp which is used as a base for the calculation of relative dates.

Description

The function expects to be given a string containing a US 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 now, or the current time if now is not supplied.

Version

PHP 4, 5

Return value

Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1on failure.