info about link
: Javascript : PHP Index : MySQL :
date difference
: Source : : Explanation : : Example : : Todo : : Feedback :
<?php
$s 
date("2006-08-01 14:35:07");
$e date("2007-01-05 03:59:59");
echo 
dateDifference($s$e);
?>

Will result in the following output:
5 months, 3 days and 13 hours, 24 minutes, 52 seconds

<?php
print_r
(dateDifference($s$e"assoc_array"));
 
// and
print_r(dateDifference($s$e"array"));
?>
Array (
	[year] => 0
	[month] => 5
	[day] => 3
	[hour] => 13
	[minute] => 24
	[second] => 52
	)
and
Array (
	[0] => 0
	[1] => 5
	[2] => 3
	[3] => 13
	[4] => 24
	[5] => 52
	)


Some more examples of valid input:
<?php
$s 
"2006-8-1 14:35:07";
$e "2007-1-5 3:59:59";

$s "last monday";
$e "next thursday";

$s "12 September 2003";
$e "20th June";
?>


See http://www.php.net/strtotime
and http://www.gnu.org/software/tar/manual/html_node/tar_109.html
for more information on valid input
=[Disclaimer]=     © 2005-2010 Excudo.net