strtotime

(PHP 3>= 3.0.12, PHP 4 >= 4.0.0)

strtotime --  Parse about any english textual datetime description into a UNIX timestamp

Description

int strtotime (string time [, int now])

The function expects to be given a string containing an english date format and will try to parse that format into a UNIX timestamp. Upon failure, -1 is returned.

Example 1. strtotime() examples

echo strtotime ("now") . "\n";
echo strtotime ("10 September 2000") . "\n";
echo strtotime ("+1 day") . "\n";
echo strtotime ("+1 week") . "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds") . "\n";

Example 2. Checking for failure

$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
    echo "The string ($str) is bogus";
} else {
    echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}



Banner.Novgorod.Ru