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

Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a

Handling text changed in text box control using Ajax
I need to create a web form with a text box control. When someone types text into the textbox I nee

Connecion issue
Hi,

For some reason, I keep getting this error when trying to connect:

Warning: mysql_

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

RadioButtonList data selection
view plaincopy to clipboardprint?

help countdown timers
hello every one,

I'd like to know how to insert many countdowns in the same page.
The dura

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

timed header image rotation
I have a joomla site and I was trying to setup a rotating image based on timing NOT just refreshing

Combining Two Queries
I have two scripts that each work fine by themselves. One is a search script with a variable that de

Echoing If Function?
A script I am using has If statements in the comments form to basically tell the form what to do. Cu

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