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:

Did you know?Explore Trending and Topic pages for more stories like 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

remove innitial

and

tags
i am using tiny_mce as a text editor for my CMS.
buy now the problem is it add <p>

InternetOpenUrl() Invalid cert
Hi all,

Does anyone know how to prevent calls to InternetOpenUrl() from failing with erro

How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.
I'll create a table called "Use

Shuffle Array
Hi,

I am writing a script for a game that needs players to randomly be assigned a target (ano

How many users online in the last 24-hours using time()?
I'm fairly new to PHP. I have a MySQL table called 'users' and a field called 'loggedin' which is in

Simple AND question
Hello,

I've got following code:

Code: if(strpos($row[13],"http://")

Why use OOP?
Can someone explain to me why I should use OOP instead of procedure based code.

Im building a

using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto

present value of sequence?
Hi

Please help me to find out the present value of sequence?

Thanks

getting weird error..
okay, I'm getting an error on this particular function, something about the syntax in the mysql LIMI

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