In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use the PHP timestamp strtotime () function". In the operation of actual cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Gets the specified year, month and day converted to a timestamp:
The pHP timestamp function gets the unix timestamp strtotime of the specified date ('2012-12-7')
Examples are as follows:
The copy code is as follows:
Description: returns the 00:00:00 timestamp on December 7, 2012.
Convert the current year, month and day into a timestamp: the PHP timestamp function gets the unix timestamp of the current date
Examples are as follows:
The copy code is as follows:
Ming: returns the timestamp of the current time, year, month, day, hour and second.
Convert the timestamp to the year, month and day:
The copy code is as follows:
Example
The copy code is as follows:
PHP timestamp function to get the date and time of English text
For easy comparison, use date to convert the current timestamp and the specified timestamp into system time
(1) print the timestamp strtotime ("+ 1 day") at this time tomorrow
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("+ 1 day")) result: 2009-01-23 09:40:25
(2) print the timestamp strtotime ("- 1 day") of this time yesterday.
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("- 1 day")) result: 2009-01-21 09:40:25
(3) print the timestamp strtotime ("+ 1 week") at this time next week.
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("+ 1 week")) result: 2009-01-29 09:40:25
(4) print the timestamp strtotime ("- 1 week") at this time last week.
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("- 1 week")) result: 2009-01-15 09:40:25
(5) print the timestamp strtotime ("next Thursday") that specifies the day of next week.
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("next Thursday")) result: 2009-01-29 00:00:00
(6) print the timestamp strtotime ("last Thursday") that specifies the day of the previous week.
Current time: echo date ("Y-m-d H:i:s", time ()) result: 2009-01-22 09:40:25
Specified time: echo date ("Y-m-d H:i:s", strtotime ("last Thursday")) result: 2009-01-15 00:00:00
That's all for "how to use the PHP timestamp strtotime () function". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.