Find Leap Year - Php

How to find whether a year is leap year or not using php code?

Snippet Code


  
Rate this page :
  [ 0 votes]

Use this php code to find whether a year is a leap year or not. Here, date(‘L’) is the parameter which returns 1 if it’s a leap year, 0 if it isn’t.

<?php function leapyear($year){ $isLeapYear = (bool) date('L', strtotime("$year-01-01")); return $isLeapYear; } $result = leapyear('2015'); if($result=='1') { echo "Year is leap year"; } else{ echo "Year is not leap year"; } ?>

Tags


Ask Questions

Ask Question