1. Obtain the unix timestamp of the specified date
Strtotime ("2009-1-22") example:
1. echo strtotime ("2009-1-22 ")
Result: 1232553600
Returns the January 22, 2009 00:00:00 timestamp.
2. Obtain the date and time of the English text
Example:
For ease of comparison, date is used to convert a timestamp from a specified timestamp to a system time
(1) print the timestamp strtotime ("+ 1 day") at this time tomorrow ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("+ 1 day "))
Result: 09:40:25
(2) print the timestamp strtotime ("-1 day") at this time yesterday ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("-1 day "))
Result: 09:40:25
(3) print the timestamp strtotime ("+ 1 week") for the next week ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("+ 1 week "))
Result: 09:40:25
(4) print the timestamp strtotime ("-1 week") of the last week ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("-1 week "))
Result: 09:40:25
(5) print the specified timestamp strtotime for the next week ("next Thursday ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("next Thursday "))
Result: 00:00:00
(6) print the timestamp strtotime of the specified last week ("last Thursday ")
Current time:
1. echo date ("Y-m-d H: I: s", time ())
Result: 09:40:25
Specified Time:
1. echo date ("Y-m-d H: I: s", strtotime ("last Thursday "))
Result: 00:00:00
The preceding example shows that strtotime can parse the datetime description of any English text into a Unix timestamp. We can use mktime () or date () to format the datetime to get the specified timestamp, the date and time required for implementation.