Is there a function that will ...?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Is there a function that will ...?

Post by virgil »

Hey PhP's :D

Is there a function that will return the difference between two dates?

i.e. Jul 15, 2002 - Aug 15, 2002 = 31 Days

Thanks..... Virgil
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

<?
$_14 = mktime(0,0,0,7,14,2002);
$_to = time();
$_re = $_14 - $_to;
$_rem = $_re / 60;
$_reh = $_rem / 60;
$_red = $_reh / 24;

echo "<table cellpadding=3>";
echo "<tr><td>Seconds: </td><td>$_re</td></tr>";
echo "<tr><td>Minutes: </td><td>$_rem</td></tr>";
echo "<tr><td>Hours: </td><td>$_reh</td></tr>";
echo "<tr><td>Days: </td><td>$_red</td></tr>";
echo "</table>";

?>
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Post by virgil »

Thanks Hob. That works, but is there a simple way to convert
"Aug 15, 2002" to "0,0,0,8,15,2002"?
Post Reply