Home >Backend Development >PHP Problem >How to convert timestamp in php date
How to convert date to timestamp in php: First create a PHP sample file; then use the "echo strtotime("now"), "\n";" method to convert date to timestamp.
Recommended: "PHP Video Tutorial"
Use the strotime function, the code is as follows;
<?php 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"; echo strtotime("20170808 23:00:01"), "\n"; ?>
Extended information:
PHP strtotime() function
1.strtotime, a function that can convert American English format time strings.
2.strtotime() can create a timestamp of a certain moment in English natural language
3. Function syntax: int strtotime(string $time[,int $now])
4. Function: Convert date and time strings in US English format into unix timestamps.
The above is the detailed content of How to convert timestamp in php date. For more information, please follow other related articles on the PHP Chinese website!