Jump to content


Photo

calc from logtime and logout time


  • Please log in to reply
4 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 March 2006 - 05:36 AM

How can i work out the time remaning from my time varables

please help me,How to code this up properly thank you.

<?
$login_time=(h,m,s);//get login time hour min sec.

$logout_time=(h,m,s);//get logout time hour min sec.

$remaningtime=('$login_time<>$logout_time');//calc the diffrence.

echo $remaningtime;//echo the remaning time
?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 March 2006 - 06:21 AM

[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]please goto ken code below to help thank you.[!--sizec--][/span][!--/sizec--]



This code gives the effect i wont but i need to get the two times from the database then get the result
the time was posted in the database as this format time(h,m,s)

so what i need is to get that info out of the database in the below code format but how thank you.

<?
// Pass epoch timestamps
function calcDateDiff ($date1 = 0, $date2 = 0) {

   // $date1 needs to be greater than $date2.
   // Otherwise you'll get negative results.
   if ($date2 > $date1)
       return FALSE;

   $seconds  = $date1 - $date2;

   // Calculate each piece using simple subtraction

   $weeks     = floor($seconds / 604800);
   $seconds -= $weeks * 604800;

   $days       = floor($seconds / 86400);
   $seconds -= $days * 86400;

   $hours      = floor($seconds / 3600);
   $seconds -= $hours * 3600;

   $minutes   = floor($seconds / 60);
   $seconds -= $minutes * 60;

   // Return an associative array of results
   return array( "weeks" => $weeks, "days" => $days, "hours" => $hours, "minutes" => 

$minutes, "seconds" => $seconds);
}


// Example: current timestamp with 22:00 12th, January 2003 or use variable(s)
if ($diff = calcDateDiff(time(), mktime(22, 00, 00, 1, 12, 2003))) { 
   //Format output any way you like
   printf("Difference between the two dates is: %d week(s), %d day(s), %d hour(s), %d 

minute(s), %d second(s).", $diff['weeks'], $diff['days'], $diff['hours'], 

$diff['minutes'], $diff['seconds']); 
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 March 2006 - 06:34 AM


please help unusall errow what do i do.

my error
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\Program Files\Apache Group\Apache2\htdocs\collage\time.php on line 55
Start: 

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\Program Files\Apache Group\Apache2\htdocs\collage\time.php on line 56
End: 
There are 0 days, 0 hours and 0 minutes left

The code i am currently using
<?
//change user and password to your mySQL name and password
mysql_connect("xxxx","xxxx","xxxx"); 

//select which database you want to edit
mysql_select_db("jojo"); 


//If cmd has not been initialized
if(!isset($tmp)) 

{
  //display all the news
$tmp=mysql_query("SELECT * FROM log");
while ($row = mysql_fetch_assoc($tmp))
  { 
     //grab the title and the ID of the news
$logout_time=$row["logout_time"];//take out the id 

 $minute = 60;
    $hour = 60 * 60;
    $day = $hour * 24;
    $logout_time = strtotime('logout_time');
    $login_time = strtotime('login_time');
    $seconds_left = $logout_time - $login_time;
    $days_left = floor($seconds_left / $day);
    $hours_left = floor(($seconds_left % $day)/$hour);
    $minutes_left = floor((($seconds_left % $day) % $hour) / $minute);
    echo 'Start: ' . date('m/d/Y G:i',$login_time) . "<br />\n";
    echo 'End: ' . date('m/d/Y G:i',$logout_time) . "<br />\n";
    echo 'There are ' . $days_left . ' days, ' . $hours_left . ' hours and ' . 
$minutes_left . ' minutes left';
}
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 March 2006 - 09:24 AM

[!--quoteo(post=356349:date=Mar 19 2006, 06:34 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 19 2006, 06:34 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
please help unusall errow what do i do.

my error
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\Program Files\Apache Group\Apache2\htdocs\collage\time.php on line 55
Start: 

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\Program Files\Apache Group\Apache2\htdocs\collage\time.php on line 56
End: 
There are 0 days, 0 hours and 0 minutes left

The code i am currently using
<?
//change user and password to your mySQL name and password
mysql_connect("xxxx","xxxx","xxxx"); 

//select which database you want to edit
mysql_select_db("jojo"); 
//If cmd has not been initialized
if(!isset($tmp)) 

{
  //display all the news
$tmp=mysql_query("SELECT * FROM log");
while ($row = mysql_fetch_assoc($tmp))
  { 
     //grab the title and the ID of the news
$logout_time=$row["logout_time"];//take out the id 

 $minute = 60;
    $hour = 60 * 60;
    $day = $hour * 24;
    $logout_time = strtotime('logout_time');
    $login_time = strtotime('login_time');
    $seconds_left = $logout_time - $login_time;
    $days_left = floor($seconds_left / $day);
    $hours_left = floor(($seconds_left % $day)/$hour);
    $minutes_left = floor((($seconds_left % $day) % $hour) / $minute);
    echo 'Start: ' . date('m/d/Y G:i',$login_time) . "<br />\n";
    echo 'End: ' . date('m/d/Y G:i',$logout_time) . "<br />\n";
    echo 'There are ' . $days_left . ' days, ' . $hours_left . ' hours and ' . 
$minutes_left . ' minutes left';
}
}
?>
[/quote]

Going relly mad never work this out 4 hours later still error please help. eyes red lol advance thank you

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 March 2006 - 11:09 AM

[!--quoteo(post=356374:date=Mar 19 2006, 09:24 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 19 2006, 09:24 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Going relly mad never work this out 4 hours later still error please help. eyes red lol advance thank you
[/quote]

can somone please help thank you.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users