Created
August 4, 2015 12:00
-
-
Save cdmz/54ff86ef73fd4034774f to your computer and use it in GitHub Desktop.
Function print days left birthday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function daysLeftForBirthday($birthdate) { | |
/* input date format -> Y-m-d */ | |
list($y, $m, $d) = explode('-',$birthdate); | |
$nowdate = mktime(0, 0, 0, date("m"), date("d"), date("Y")); | |
$nextbirthday = mktime(0,0,0,$m, $d, date("Y")); | |
if ($nextbirthday<$nowdate) | |
$nextbirthday=$nextbirthday+(60*60*24*365); | |
$daycount=intval(($nextbirthday-$nowdate)/(60*60*24)); | |
return $daycount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment