How can I calculate difference between the current date and another date, got from database, into hours using php?
I found this example
$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.";
But my first date ( $century in this example ) isn't static. How should i modify the code? What date format should I use? Do you happen to have any better code?
Can anyone please help?