In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use php to obtain the number of days of the month and the first and last day of the month, and the first and last day of the month". In the daily operation, I believe many people have doubts about how to use php to obtain the number of days of the month and the first and last day of the month, the first and last day of the month. The editor consulted all kinds of materials and sorted out a simple and useful method of operation. I hope it will be helpful for you to answer the question of "how to use php to get the number of days of the month and the first and last day of the month, and the first and last day of the month"! Next, please follow the editor to study!
1. Get the first and last day of the last month.
Echo date ('YmurmMuo01, strtotime ('-1 month'))
Echo ""
Echo date ('YmurmMuttong, strtotime ('-1 month'))
Echo ""
There are some problems with the above method. Modify it according to the bg5hfc reply.
The first day of last month:
Echo date ('Ymurm Murphy 01'), strtotime (date). ('- 1 month')); / / calculate that the first day of the month will be subtracted by another month.
The last day of last month:
Echo date ('Ymurm Murphy 01'), strtotime (date). ('- 1 day')); / / calculate the first day of the month minus one more day.
two。 Get the first and last day of the month.
$BeginDate=date ('Ymurmmur01mm, strtotime (date ("Y-m-d")
Echo $BeginDate
Echo ""
Echo date ("$BeginDate + 1 month-1 day")
Echo ""
3. Get the year, month, day and number of days of the day.
"echo" this month: ". Date (" t ")." days "
Echo "current year" .date ('Y')
Echo "current month" .date ('m')
Echo "what's the current date" .date ('d')
Echo ""
4. It is more practical to use functions and arrays to get the first and last day of the month.
Function getthemonth ($date)
{
$firstday = date ('Ymurmmur01mm, strtotime ($date))
$lastday = date ("$firstday + 1 month-1 day")
Return array ($firstday,$lastday)
}
$today = date ("Y-m-d")
$day=getthemonth ($today)
Echo "first day of the month:". $day [0]. "the last day of the month:". $day [1]
Echo ""
At this point, the study on "how to use php to obtain the number of days of the month and the first and last day of the month, the first and last day of the month" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.