note 14434 added to function.mktime.php

From: Date: Tue, 31 Jul 2001 12:47:58 +0000
Subject: note 14434 added to function.mktime.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16097@lists.php.net to get a copy of this message
This is simple code for calculating current age and day's till next birthday: // first get the current date $nowdate = mktime(0,0,0,date("m"),date("d"),date("Y")); // this is my birthday $birthday = mktime(0,0,0,"10","28","1980"); // calculate my age in years $age=intval(($nowdate-$birthday)/(60*60*24*365)); echo "I'm now $age years old."; // my next birthday $nextbirthday = mktime(0,0,0,"10","28",date("Y")); // if $nextbirtday is in the past, add 1 year to $nextbirthday if ($nextbirthday<$nowdate) { $nextbirthday=$nextbirthday+(60*60*24*365); } // calculate the remaining day's till my next birthday $daycount=intval(($nextbirthday-$nowdate)/(60*60*24)); echo " My next birthday is over $daycount day's."; Dennis Heldens. http://www.php.net/manual/en/function.mktime.php

« previous php.notes (#16097) next »