date - Days remaining before birthday in php -


this question has answer here:

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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -