Fenhopi Posted November 22, 2010 Share Posted November 22, 2010 Hi! I have this to check if now is between start time and end time: [date_default_timezone_set('Europe/Belgrade'); $TimeNow = date("H:i" ,time()); $today_date = date('d-m-y'); $GetTimeTable = "SELECT * FROM timetable WHERE username='$username' AND Subject_date='$today_date'"; $ConnectTimeTable = $database->query($GetTimeTable); $TimeTable = mysql_fetch_array($ConnectTimeTable); $Subject = $TimeTable['Subject']; $Start_time = $TimeTable['Start_Time']; $End_time = $TimeTable['End_Time']; ?><br><? if($TimeNow >= $Start_time && $TimeNow <= $End_time){ echo "Current Class: "; echo $Subject; echo "<br><br>"; // a START time value $start = $TimeNow; // an END time value $end = $End_time; // what is the time difference between $end and $start? if( $diff=@get_time_difference($start, $end) ) { echo "Time left: " . sprintf( '%02d:%02d', $diff['hours'], $diff['minutes'] ); } else { echo "Hours: Error"; } } else{ echo "No class. "; } Start time and end time is displayed in the format like 14:26. For some reason this code doesn't work though, I don't get why. Link to comment https://forums.phpfreaks.com/topic/219450-checking-if-time-is-between-two-values/ Share on other sites More sharing options...
MrXHellboy Posted November 22, 2010 Share Posted November 22, 2010 Please let me know, what exactly isnt working Link to comment https://forums.phpfreaks.com/topic/219450-checking-if-time-is-between-two-values/#findComment-1137886 Share on other sites More sharing options...
Fenhopi Posted November 22, 2010 Author Share Posted November 22, 2010 When start time is 09:00 and end time is 10:00, time now is 09:30. It's supposed to echo my current class, instead it echos "no class" Link to comment https://forums.phpfreaks.com/topic/219450-checking-if-time-is-between-two-values/#findComment-1137892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.