-
- 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";
- ?>
Copy code
Example 2,
-
- $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);
- }
- ?>
-
Copy code
this The effect is the same as using mktime().
I hope the above introduction and examples will be helpful to everyone.
For the usage of php strtotime function, you can also refer to:
Detailed introduction to PHP strtotime function
Example of usage of strtotime function in PHP
Y2K38 vulnerability in strtotime() and mktime() in php 2038 issue
php timestamp function strtotime application example
Function efficiency of strtotime in php
|