Please Help my PHP Dating Function.


Posted on 16th Feb 2014 07:03 pm by admin

Hi everyone!

Well here is my code that displays this:

It works wonderful.




The code is:

Code: function time_elapsed_string($ptime) {
$etime = time() - $ptime;

if ($etime < 1) {
return '0 seconds';
}

$a = array( 12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute ago',
1 => 'second'
);

foreach ($a as $secs => $str) {
$d = $etime / $secs;
if ($d >= 1) {
$r = round($d);
return $r . ' ' . $str . ($r > 1 ? 's ago' : '');
}
}
}
But I would like it to say, instead of just 1 Minute ago, make it say "1 Minute 25 Seconds ago"

I would want to add seconds into there on the minutes.

Can somone revamp this and post again the correct way, Thanks for your patience, ( Sorry for my other topic I was too excited) I'm trying to be nice and professional for u.

No comments posted yet

Your Answer:

Login to answer
148 Like 51 Dislike
Previous forums Next forums
Other forums

COde for a Cc
I'm not receiving $ft as a Cc. Why is that??

$to = "$email";
$headers = "Fr

how make 2 column in table with data tybe long row
hi every one

I want make in my table 2 column with data tybe long raw

how thi

Email/MMS to Site
Hey guys. I'm looking for a way for a user to upload images and/or text via their cell phones. It

Save file by click
Hello.
I'm not understand how to save file from page. I'd like make link to file with save abil

Creation of Raw Exposure manually
SAP Gurus

I am creating Raw Exposure ( Hedge management ) thru T Code TEM10 with followin

The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom

problem with sql querry in php script
Hello guys,

What I want to do is I want to read out a csv file and then but te conent ot the

Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so

Taylor Series Function
So I am working a a project for my intro C++ class, and I am having some trouble with a function for

Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash