PDA

View Full Version : How to Subtract Time from Time to = Time?


TheMayhem
02-23-2005, 01:00 AM
Basically what I'm asking if I have something like
$user['dateregistered']
$currentdate

Both of those are stored in the db, how can I take the dateregistered and subtract the current date and then be able to output a new variable called something like $totaldaysregistered. And have that totaldaysegistered display the number of days, hours, and minutes total. Is there any kind of php coding we can do to get this?

Jolten
02-23-2005, 02:12 PM
$totaldaysregistered= $currentdate - $user['dateregistered'];


Then using $totaldaysregistered will give you the difference between the dates.

Xenon
02-23-2005, 03:09 PM
as you can find in member.php that way:

$jointime = (TIMENOW - $userinfo['joindate']) / 86400; // Days Joined

TheMayhem
02-26-2005, 03:27 AM
as you can find in member.php that way:

$jointime = (TIMENOW - $userinfo['joindate']) / 86400; // Days Joined

Just wondering but what exactly would the equation to then take your Days Joined total and take that remainder to output the hours as well so like 6 Days, 2 Hours, ect.?

Xenon
03-01-2005, 02:08 PM
theoretically it should be possible to use vbdate here, so in a way like:

$totallyhere = TIMENOW - $userinfo['joindate'];
$datestring = 'You are here since' . vbdate('d', $totallyhere) . ' Days' ......