In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of php how to judge whether a year is a leap year, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this php article on how to judge whether a year is a leap year. Let's take a look.
Judgment method: 1, use the "strtotime (" specified year value-02 ") statement to convert the date of the specified year into a Unix timest 2, use the" date ("t", timestamp) = = 29 "statement to get the number of days in February in the specified year, and determine whether the number of days is equal to 29, if it is a leap year, otherwise it is not a leap year.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Using php to judge whether a year is a leap year
February in a leap year has 29 days. We can use date () to get the number of days contained in February in a given year $year, and determine whether the number of days is 29 days, so that we can determine whether a given year $year is a leap year.
Implementation code:
Test it:
F (2022); f (2021); f (2020); f (2012); f (2010)
Analysis:
In the above example, the strtotime ("{$year}-02") statement converts the date in the format "xxxx-02" into a Unix timest then you can use the date ("t", $time) statement to get the number of days contained in February of the $yearbook year, and use the if statement to determine whether the number of days is equal to 29 days, you can determine whether $year is a leap year.
The "t" character parameter of the date () function can be used to get the number of days contained in a given month, and many characters are built into the function to control the format of the output date string. In fact, there is a character "L" that can be used to determine whether it is a leap year (1 if it is a leap year, otherwise 0).
This is the end of the article on "how php determines whether a year is a leap year or not". Thank you for reading! I believe you all have a certain understanding of "how to judge whether a year is a leap year or not". If you want to learn more, you are welcome to follow the industry information channel.
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.