Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Elapsed Time Function
Old 08-18-2008, 10:30 PM Elapsed Time Function
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Whoops, appear to have a problem with this elapsed time function.. It's incorrectly showing the time.

For example. 1 days and 46 hours ago.

Sorry I am tired so if it is simple please gimme a poke

PHP Code:
function elapsed_time($timestamp) {
$curTimestamp time() - (60*60);
$difference $curTimestamp strtotime($timestamp);
switch(
$difference) {
case (
$timestamp == 0):
return 
"Few seconds ago!";
break;
case (
$difference <= 3600):
return 
round($difference 60, -0.5)." minutes ago";
break;
/*case ($difference <= 900):
return "One quarter ago";
break;*/
case ($difference <= 1800):
return 
round($difference 60, -0.5)." minutes ago";
break;
case (
$difference <= 2700):
return 
"Half an hour ago";
break;
/*case ($difference <= 3600):
return "Three quarters ago";
break;*/
case ($difference <= 86400):
$minutes floor(($difference 3600) / 60);
if(
$minutes 0) {
return 
floor($difference 3600)." hours and $minutes minutes ago";
} else {
return 
floor($difference 3600)." hours ago";
}
break;
case (
$difference <= 172800):
return 
floor($difference 86400)." day and ".floor(($difference 86400) / 3600)." hours ago";
break;
case (
$difference 172800):
return 
floor($difference 172800)." days and ".floor(($difference 172800) / 3600)." hours ago";
default:
return 
date("\A\\t H:i \o\\n d-m-Y",$timestamp);
}

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 08-19-2008, 02:39 AM Re: Elapsed Time Function
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Why do you divide by 172800? It means that you try to calculate quantity of days 48 hours long.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-19-2008, 07:51 AM Re: Elapsed Time Function
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Thanks, my bad.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Reply     « Reply to Elapsed Time Function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25503 seconds with 12 queries