Skip to content

Instantly share code, notes, and snippets.

@DaveyJake
Last active April 5, 2019 17:16
Show Gist options
  • Save DaveyJake/b6f28c99f186e4bcd3ee76359746e21a to your computer and use it in GitHub Desktop.
Save DaveyJake/b6f28c99f186e4bcd3ee76359746e21a to your computer and use it in GitHub Desktop.
Check For Leap Year
<?php
/**
* Simple function to check if it's currently a 'leap year'.
*
* @return bool True if it is. False if not.
*/
function is_leap_year() {
// Ensure that '0' isn't read as boolean.
$zero = (int) 0;
// Current Year
$year = date( 'Y' );
// No remainders means it's a leap year!
return ( $year % 4 === $zero );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment