1 2 3 4 5 6 7 8 9 |
<?php echo(strtotime("now") . "<br>"); echo(strtotime("3 October 2005") . "<br>"); echo(strtotime("+5 hours") . "<br>"); echo(strtotime("+1 week") . "<br>"); echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>"); echo(strtotime("next Monday") . "<br>"); echo(strtotime("last Sunday")); ?> |
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).
Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
Note: Be aware of dates in the m/d/y or d-m-y formats; if the separator is a slash (/), then the American m/d/y is assumed. If the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. To avoid potential errors, you should YYYY-MM-DD dates or date_create_from_format() when possible.
DatesĀ format
YYYY-MM-DD HH:MM:SS
YYYY/MM/DD HH:MM:SS
MM/DD/YYYY HH:MM:SS
MM/DD/YYYY HH:MM:SS
DD-MM-YYYY HH:MM:SS