Home >Backend Development >PHP Tutorial >php strtotime function UNIX timestamp_PHP tutorial
If the format of time is absolute time, the now parameter has no effect. If the format of time is a relative time then the relative time is provided by now, or the current time if no now argument is provided. Returns -1 on failure.
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";
echo strtotime ("next Thursday"), "n";
echo strtotime ("last Monday"), "n";
?>$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);
}
?>
This effect is the same as using mktime().