{"id":75,"date":"2009-07-07T02:15:00","date_gmt":"2009-07-07T06:15:00","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/programming-blog\/php-code-to-find-leap-year-or-not\/"},"modified":"2017-07-16T23:57:02","modified_gmt":"2017-07-17T03:57:02","slug":"php-code-to-find-leap-year-or-not","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/programming-blog\/php-code-to-find-leap-year-or-not\/","title":{"rendered":"Php code to find leap year or not"},"content":{"rendered":"<p>We can find a year is leap year or not in various ways.we can use the following fuctions in php.<\/p>\n<ul>\n<li>By using date() function<\/li>\n<li>By Modulus operator<\/li>\n<\/ul>\n<p>Here is a sample php code that uses modulus(%)operator for finding the leap year.<\/p>\n<p>Write the below code within php tags<\/p>\n<p>[php]<br \/>\n&lt;code&gt;<br \/>\n &lt;!&#8211;?PHP &lt;\/p&#8211;&gt; &lt;\/code&gt;<\/p>\n<p>&lt;code&gt;$start = 1000;<br \/>\n $end = 1011;<br \/>\n for($i = $start; $i &lt; $end; $i++)<br \/>\n {<br \/>\n if(($i%4) == 0){$val = &quot;Leap Year&quot;;}else{$val = &quot;Not Leap Year&quot;;}<br \/>\n echo $i, &#8216; &#8212;&gt; &#8216;.$val.&#8221;;<br \/>\n }&lt;\/code&gt;<\/p>\n<p>?&gt;<br \/>\n[\/php]<\/p>\n<p>It will produce the output as given below.<\/p>\n<p>1000 &#8212;&gt; Leap Year<br \/>\n1001 &#8212;&gt; Not Leap Year<br \/>\n1002 &#8212;&gt; Not Leap Year<br \/>\n1003 &#8212;&gt; Not Leap Year<br \/>\n1004 &#8212;&gt; Leap Year<br \/>\n1005 &#8212;&gt; Not Leap Year<br \/>\n1006 &#8212;&gt; Not Leap Year<br \/>\n1007 &#8212;&gt; Not Leap Year<br \/>\n1008 &#8212;&gt; Leap Year<br \/>\n1009 &#8212;&gt; Not Leap Year<br \/>\n1010 &#8212;&gt; Not Leap Year<\/p>\n<p>You find leap years for any year ranges by changing the $start and $end.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can find a year is leap year or not in various ways.we can use the following fuctions in php. By using date() function By Modulus operator Here is a sample php code that uses modulus(%)operator for finding the leap year. Write the below code within php tags [php] &lt;code&gt; &lt;!&#8211;?PHP &lt;\/p&#8211;&gt; &lt;\/code&gt; &lt;code&gt;$start = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[152,15],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-php","tag-php","tag-php-code"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":12,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":820,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/75\/revisions\/820"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}