Skip to content

Instantly share code, notes, and snippets.

@PogHallam
Last active September 17, 2019 16:58
Show Gist options
  • Save PogHallam/1194209ffa62097e16990f50f383dd09 to your computer and use it in GitHub Desktop.
Save PogHallam/1194209ffa62097e16990f50f383dd09 to your computer and use it in GitHub Desktop.
/**
* Given a timestamp, return true if it is a leap year.
*
* @param int $timestamp A unix timestamp.
*
* @return bool
*/
function is_leap_year( int $timestamp ): bool {
return (bool) date( 'L', $timestamp );
}
/**
* Given a timestamp, return true if it is February in a leap year.
*
* @param int $timestamp
*
* @return bool
*/
function is_leap_february( int $timestamp ): bool {
return is_leap_year( $timestamp ) && date( "m", $timestamp ) === '02';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment