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

Online Event Ticket Sales
Has anyone wrote a script for online tickets sales?

I have been googling and found lots of th

Deleting pointers froms vector?
Hi. I have a vector filled with pointers and I want to delete the pointers. I could do a loop and do

I need help with formatting date from mysql! with php!
Hello guys

*Note: this is a php question not MySQL question, please do not move it to mysql s

PHP Directory Listing Not working
Hey Guys,

I need help, I tried a ton of directory listing scripts and they all don't work. Al

Reading waves
Hi,

I am trying to find a way of finding the highs and lows on a graph line, the line points

how to timeout $doc = new DOMDocument()->load($url)
I am currently using this $doc->load($url) to fetch an rss feed.
If a feed takes long than

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

Gridview Not updating in Update Panel
I have a gridview, three dropdown list boxes, and a button on my form. What is displayed in the gri

How do I create a 2D game "camera" to follow player?
In J2ME programming I'm targeting MIDP 2.0 devices.

I'm using gamecanvas and I was thinking t

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

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