## Recommended Posts

Yeah but the full string is needed.

• Replies 56
• Created

#### Popular Days

the Gayner is just adding something like seconds i dont know why you guys are making it so hard. im pretty sure all that he neeeds to do is divide the etime variable by  60 and then use that one function to uh... get the remainder...(dont round)

JUST FMOD() THE DARN THING!

$etime = 428939; ///the number differnce$minute = 60;
$seconds = fmod($etime, $minute); echo$seconds;

i think ive stuck gold here folks. i was right about the main point. this is the EASIEST WAY TO ASS SECONDS. nd if u reread thats what Gayner asked.

u guys are u incoherent? i figured it out. look!

##### Share on other sites

Obvious Troll is Obvious, lol

##### Share on other sites

xcuse me i just figured it out for you. obvious ignornant postrs are obvious.. but not to themselves..... obviously! cause they are IGNORING THE SOLUTION!

##### Share on other sites

while im here i feel this is relevant, in a for each loop is there any way to return the value of a key numerically so that the next key and its value can be accessed while in the current loop?

##### Share on other sites

Not without altering the current position of the array.

##### Share on other sites

• 2 weeks later...

This works?

Could probably be shortened but just as a concept:

<?php
function timeDifference($previousTime) {$epoch = time();
$differenceEpochPrevious =$epoch - $previousTime;$differencePreviousNow = time() - $differenceEpochPrevious;$timeDifferences = array(
'year' => date('Y') - date('Y', $differencePreviousNow), 'month' => date('m') - date('m',$differencePreviousNow),
'day' => date('d') - date('d', $differencePreviousNow), 'hour' => date('H') - date('H',$differencePreviousNow),
'minuite' => date('i') - date('i', $differencePreviousNow), 'second' => date('s') - date('s',$differencePreviousNow),
);

$outputString = ''; foreach($timeDifferences as $timeString =>$value)
{
if($value > 1) {$outputString .= $value . ' ' .$timeString . 's ';
} elseif($value > 0) {$outputString .= $value . ' ' .$timeString . ' ';
}
}

$outputString .= 'ago.'; return$outputString;
}

echo(timeDifference(strtotime('-1 year -12 months')));
?>


YES FINALLY!!

8minutes, 20second's ago! HAha I FINALLY Got this to work thanks to u bro!!!

I Really love you no homo but seriously, this script is epic, kudo's to ur brain and soul my broski!

lol All i needed was the 20second's ago added to the 8minutes, took us 4pages but i got it!

THANKS!

AWW CRAP::

Whenever u get to the next minute, it stays at 11minutes ago until the first minute is up then it start's displaying the second after, could u fix this?

##### Share on other sites

This thread is more than a year old.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
×
• Create New...