When we need to calcualate the no of days between two days. We convert the current date and the previous date into the time and calculate the no of days.
Php code :
<?php
$century = mktime(12, 0, 0, 1, 1, 2001);
$today = time();
$difference = $today - $century;
echo 'This century started ';
echo floor($difference / 84600);
$difference -= 84600 * floor($difference / 84600);
echo ' days, ';
echo floor($difference / 3600);
$difference -= 3600 * floor($difference / 3600);
echo ' hours, ';
echo floor($difference / 60);
$difference -= 60 * floor($difference / 60);
echo " minutes, and $difference seconds ago.";
?>
Here in the above example you can count the days difference between 2 days and minutes and seconds also.
Saturday, March 7, 2009
Calculate No of Days between two dates
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment