date - Days remaining before birthday in php -
this question has answer here:
- php how many days , hours left date 7 answers
i have 2 variables in php script:
$birthday = "1977-10-03"; $now = time(); how calculate days remaining before birthday ($daysremaining = ?)
duplicate date difference in php on days?
edited:
$diff=$date-time();//time returns current time in seconds $days=floor($diff/(60*60*24));//seconds/minute*minutes/hour*hours/day) $hours=round(($diff-$days*60*60*24)/(60*60)); is how wanted?
$birthday = "1977-9-10"; $cur_day = date('y-m-d'); $cur_time_arr = explode('-',$cur_day); $birthday_arr = explode('-',$birthday); $cur_year_b_day = $cur_time_arr[0]."-".$birthday_arr[1]."-".$birthday_arr[2]; if(strtotime($cur_year_b_day) < time()) { echo "birthday passed year"; } else { $diff=strtotime($cur_year_b_day)-time();//time returns current time in seconds echo $days=floor($diff/(60*60*24)); }
Comments
Post a Comment