We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

Scooter on 03/12/08


Tagged

DateTime


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

Netzach


Check if a year is a leap year


Published in: PHP 


URL: http://reusablecode.blogspot.com

Function to check if a given year is a leap year.


  1. <?php
  2. /*
  3.   Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  4.   Thanks to Jim Mayes for showing me a more elegant solution.
  5.  
  6.   This work is licensed under the Creative Commons Attribution License. To view
  7.   a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  8.   send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  9.   94305, USA.
  10.   */
  11.  
  12. // Check if a year is a leap year.
  13. function isLeapYear($someYear)
  14. {
  15. return date("L", strtotime($someYear . "-01-01"));
  16. }
  17. ?>

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: jimmayes on March 26, 2008

function is_leapyear($year){ return date("L", strtotime($year . "-01-01")); }

You need to login to post a comment.