PHP Date Exercises : Count the number of days between current day and birthday
PHP date: Exercise-2 with Solution
Create a simple 'birthday countdown' script, the script will count the number of days between current day and birthday.
<?php $target_days = mktime(0,0,0,12,31,2013);// modify the birth day 12/31/2013 $today = time(); $diff_days = ($target_days - $today); $days = (int)($diff_days/86400); print "Days till next birthday: $days days!"."\n"; ?>
Days till next birthday: -1143 days!
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a PHP script which will display the copyright information in the following format. To get current year you can use the date() function.
Next: Write a PHP script to print the current date in the following format. To get current date's information you can use the date() function.
What is the difficulty level of this exercise?