michael-lane
10-19-2005, 11:14 AM
i want to make a page where someone types in a future date then it calculates exactly how long it is till that date in this format "that date is 10 days, 2 months, 0 years, 0 hours, 1 minute, 32 seconds till ....."
so could someone knock me up a code so i could adapt it for my script?
Dan Grossman
10-19-2005, 03:38 PM
http://www.ilovejackdaniels.com/php/php-datediff-function/ may help
azizny
10-20-2005, 12:51 PM
//End date is current date
//$start_date, lets say sep 05 82 : 00:00:00
$seconds_dif = mktime(date("G"),date("i"),date("s"),date("m"),date("d"),date("Y")) - mktime('00','00','00','09','05','1982');
//Difference in seconds is $seconds_dif
//Now only math calculation to figure out months/years..
echo '<br />Years Difference = '. floor($seconds_dif/365/60/60/24);
echo '<br />Months Difference = '. floor($seconds_dif/60/60/24/7/4);
echo '<br />Weeks Difference = '. floor($seconds_dif/60/60/24/7);
echo '<br />Days Difference = '. floor($seconds_dif/60/60/24);
echo '<br />Hours Difference = '. floor($seconds_dif/60/60);
echo '<br />Minutes Difference = '. floor($seconds_dif/60);
Peace,