Jump to content

Recommended Posts

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

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

<?
$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
?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/5275-calc-from-logtime-and-logout-time/
Share on other sites

[!--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.

[code]
<?
// 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']);
}
?>
[/code]

please help unusall errow what do i do.

my error
[code]
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
[/code]

The code i am currently using
[code]
<?
//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';
}
}
?>
[/code]
[!--quoteo(post=356349:date=Mar 19 2006, 06:34 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 19 2006, 06:34 AM) [snapback]356349[/snapback][/div][div class=\'quotemain\'][!--quotec--]
please help unusall errow what do i do.

my error
[code]
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
[/code]

The code i am currently using
[code]
<?
//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';
}
}
?>
[/code]
[/quote]

Going relly mad never work this out 4 hours later still error please help. eyes red lol advance thank you
[!--quoteo(post=356374:date=Mar 19 2006, 09:24 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 19 2006, 09:24 AM) [snapback]356374[/snapback][/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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.