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
Old 04-05-2005, 06:18 PM time?
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
I have a problem, when someone does a certain action i have a script that puts the current timestamp into mysql, how do i take that out of mysql check against the current time to see if 5 hours have past, and if it hasn't, show how many hours minutes and seconds until it does. i have tried lots of things but i can't get it to work.
timsquash5 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-05-2005, 08:17 PM
Skilled Talker

Posts: 62
Trades: 0
PHP Code:
$time = ;//Make a current timestamp, subtract 300 seconds, 
select from table_name where time $time 
The Jasong is offline
Reply With Quote
View Public Profile
 
Old 04-05-2005, 10:02 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
What have you got so far?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-06-2005, 08:46 AM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
not a lot, i can't think how to do it

PHP Code:
$check_t mysql_query("SELECT toy_quest FROM users WHERE username = '$YourName'");
$check_time mysql_result($check_t,0);
$difference = (time() - $check_time);
$wait 18000;
if (
$difference $wait)
{
//do stuff
}
else
{
$how_long $wait $difference;
$hours date("G"$how_long);
$minutes date("i"$how_long);
$seconds date("s"$how_long);
echo 
"You have " $hours " hours, " $minutes " minutes and " $seconds " seconds, to wait";

and i'v just made that up so i'm not sure if that will work.

Last edited by timsquash5; 04-06-2005 at 08:50 AM..
timsquash5 is offline
Reply With Quote
View Public Profile
 
Old 04-06-2005, 10:27 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
This might help: http://www.webmaster-talk.com/showthread.php?t=26971
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-06-2005, 11:38 AM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
Well it's not a DATETIME field so i don't think i could use that.
timsquash5 is offline
Reply With Quote
View Public Profile
 
Old 04-07-2005, 07:21 PM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
can anyone help?
timsquash5 is offline
Reply With Quote
View Public Profile
 
Old 04-07-2005, 08:15 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Ok, I put this together:

PHP Code:
<?php

include '../../connect.php';
connect();

mysql_query("create temporary table testtime(t int)");
for(
$i 1112899709$i<1112910909$i+=50) {
  
mysql_query("insert into testtime values($i)");
}

$resultmysql_query("select t as tstamp from testtime");

$timenow=time();
echo 
"time now: $timenow<br />";
for(
$i 0$i<mysql_num_rows($result); $i++){
  
$t mysql_result($result,$i,'tstamp');

  echo 
"timestamp $t: ";
  if(
$timenow-$t 18000) echo "This was over 5 hours ago<br />";
  else {
    
$remaining 18000-($timenow-$t);
    
$seconds $remaining 60;
    
$minutes = (($remaining-$seconds)/60) % 60;
    
$hours = (($remaining-$seconds-$minutes)/3600) % 24;

    echo 
"$hours hours, $minutes minutes, $seconds seconds remaining before 5 h\
ours is up.<br />"
;
  }
}
echo 
time();
?>
Result:

Code:
time now: 1112919255
<snip>
timestamp 1112901059: This was over 5 hours ago
timestamp 1112901109: This was over 5 hours ago
timestamp 1112901159: This was over 5 hours ago
timestamp 1112901209: This was over 5 hours ago
timestamp 1112901259: 0 hours, 0 minutes, 4 seconds remaining before 5 hours is up.
timestamp 1112901309: 0 hours, 0 minutes, 54 seconds remaining before 5 hours is up.
timestamp 1112901359: 0 hours, 1 minutes, 44 seconds remaining before 5 hours is up.
timestamp 1112901409: 0 hours, 2 minutes, 34 seconds remaining before 5 hours is up.
timestamp 1112901459: 0 hours, 3 minutes, 24 seconds remaining before 5 hours is up.
timestamp 1112901509: 0 hours, 4 minutes, 14 seconds remaining before 5 hours is up.
timestamp 1112901559: 0 hours, 5 minutes, 4 seconds remaining before 5 hours is up.
timestamp 1112901609: 0 hours, 5 minutes, 54 seconds remaining before 5 hours is up.
timestamp 1112901659: 0 hours, 6 minutes, 44 seconds remaining before 5 hours is up.
timestamp 1112901709: 0 hours, 7 minutes, 34 seconds remaining before 5 hours is up.
timestamp 1112901759: 0 hours, 8 minutes, 24 seconds remaining before 5 hours is up.
<snip>
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-07-2005, 08:20 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(your_timestamp_col) AS diff FROM whatever WHERE whatever
PHP Code:
if ($row['diff'] > 18000)
{
  
// Five hours have passed
}
else
{
  
// Time still to go, in seconds
  
$still_to_go 18000 $row['diff'];

__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-07-2005, 08:21 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
LOL me and oberon posted at the same time
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to time?
 

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.51223 seconds with 12 queries