Jump to content


Photo

help code thank you.


  • Please log in to reply
6 replies to this topic

#1 redarrow

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

Posted 20 March 2006 - 04:15 PM

I am trying to get login_time equal to stroftime row login_time please help thank you.


This will print what time is in the database but i need to add stroftime also how thank you.
$login_time =$row["login_time"]; 


I tried this way any other way at the same time print the time from the database with the stroftime added thank you.
$login_time =(stroftime($row["login_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 20 March 2006 - 04:44 PM


how can i calclate the diffrence between these two time varables with the ramaing time left.
thank you.



$login_time=$row['login_time']; 
$logout_time=$row['logout_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

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 March 2006 - 04:45 PM

I'm not exactly sure what you're asking, as your english isn't that great, but if you want to get a formatted string from the database, you have to use the date() function with a time/date format:

$login_time = date("n/j/Y h:i:s A", strtotime($row["login_time"]));

Info: PHP Manual


#4 redarrow

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

Posted 20 March 2006 - 05:05 PM

why this wrong please thank you.

$now = strtotime(date("n/j/Y h:i:s A"); 

$login_time = date("n/j/Y h:i:s A", strtotime($row["login_time"]));

$logout_time = date("n/j/Y h:i:s A", strtotime($row["logout_time"]));

if($login_time > $logout_time && $now < $logout_time){ 

echo "It is ".date('n/j/Y h:i:s A',$now)." the Market is now open!<br>"; 

$still_open =($logout_time - $now)/3600; 

$still_open = number_format($still_open,2);
 
echo "It will close in $still_open hours."; 

} 
elseif($now < $login_time ||$now > $logout_time){ 

echo "The Market is now closed!<br>"; 

$until_open =($login_time - $now)+75600; 

$until_open = number_format($until_open/3600,2); 

echo "It will reopen in $until_open hours"; 
} 


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 - 05:27 PM



how can i get the hour min sec from the date of login and logout in min hour day


$minute = date('n/j/Y :i A');
    $hour = date('n/j/Y h:i:s A');
    $day = $hour * date('n/j/Y h:i:s A');

$login_time = date('n/j/Y h:i:s A', strtotime($row['login_time']));

$logout_time = date('n/j/Y h:i:s A', strtotime($row['logout_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

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 March 2006 - 05:43 PM

It's called "looking up the date() function in the manual".

Info: PHP Manual


#7 redarrow

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

Posted 20 March 2006 - 06:13 PM

maybe you can not get the diffrence of the date and time when its put in the database to out put a result

can not get the result of date to give me the remaing result from the database that holds the date and tim please help.


//change user and password to your mySQL name and password
mysql_connect("xxx","xxx","xxx"); 

//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 

$login_time=$row['login_time'];//take out the id 



$minute = 60;
    $hour = 60 * 60;
    $day = $hour * 24;


$login_time = date('n/j/Y h:i:s A', strtotime($row['login_time']));

$logout_time = date('n/j/Y h:i:s A', strtotime($row['logout_time']));

echo"<br>";

echo $logout_time;

echo"<br>";

echo $login_time;

echo"<br>";

    $seconds_left = $logout_time - $login_time;

echo $seconds_left;

    $days_left = floor($seconds_left / $day);


echo $days_left;

    $hours_left = floor(($seconds_left % $day)/$hour);

    $minutes_left = floor((($seconds_left % $day) % $hour) / $minute);



    echo 'Start: ' . date('n/j/Y h:i:s A',$login_time) . "<br />\n";
    echo 'End: ' . date('n/j/Y h:i:s A',$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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users