redarrow Posted March 20, 2006 Share Posted March 20, 2006 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.[code]$login_time =$row["login_time"]; [/code]I tried this way any other way at the same time print the time from the database with the stroftime added thank you.[code]$login_time =(stroftime($row["login_time"])); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/ Share on other sites More sharing options...
redarrow Posted March 20, 2006 Author Share Posted March 20, 2006 how can i calclate the diffrence between these two time varables with the ramaing time left.thank you.[code]$login_time=$row['login_time']; $logout_time=$row['logout_time']; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19047 Share on other sites More sharing options...
ober Posted March 20, 2006 Share Posted March 20, 2006 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:[code]$login_time = date("n/j/Y h:i:s A", strtotime($row["login_time"])); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19048 Share on other sites More sharing options...
redarrow Posted March 20, 2006 Author Share Posted March 20, 2006 why this wrong please thank you.[code]$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"; } [/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19056 Share on other sites More sharing options...
redarrow Posted March 20, 2006 Author Share Posted March 20, 2006 how can i get the hour min sec from the date of login and logout in min hour day[code]$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']));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19058 Share on other sites More sharing options...
ober Posted March 20, 2006 Share Posted March 20, 2006 It's called "looking up the date() function in the manual". Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19060 Share on other sites More sharing options...
redarrow Posted March 20, 2006 Author Share Posted March 20, 2006 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.[code]//change user and password to your mySQL name and passwordmysql_connect("xxx","xxx","xxx"); //select which database you want to editmysql_select_db("jojo"); //If cmd has not been initializedif(!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';}}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5351-help-code-thank-you/#findComment-19072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.