Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP MySQL Determining times

Featured Replies

Okay, I've had a think and I can't think of a solution to this. It would help if somebody could give me advice on what to do...

 

Is there a way if I give PHP two times (a time in and time out) such as 09:00 and 13:30 loaded from a database I can determine whether or not a certain time is in between them two times. For example, I have a PHP script that creates a daily calendar that lists each half hour interval of the working day (starting with 09:00 and ending with 17:00). using a for loop I throw out each row and echo each time in a column so I have a table looking like:

 

09:00 | TABLE CELL

09:30 | TABLE CELL

10:00 | TABLE CELL

(The same for every half hour time in between)

16:30 | TABLE CELL

17:00 | TABLE CELL

 

So is there a way I can grab an event from a database that has (for example) a time in of 09:00 and a time out of 13:30 and then for each row it will determine whether or not that row is in between the event times so in our example something would happen to all the table rows from 09:00 to 13:30. Preferably these cells would be merged and I could echo out the event name in that merged cell but een if I could just echo the event name in each row it would be fine...

 

I hope you understand.. Below is a screenshot of the calendar...

 

http://img89.imageshack.us/img89/8360/picture1owu.png

 

The code is below if that helps too...

 

   <?PHP
 $time = array("09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", "04:00", "04:30", "05:00");
 $minremainder = date('i') % 30;
 $min = date('i') - $minremainder;
 if($min < 10) {
     $min = "0" . $min;
 }
 if($day = date("j") && $month = date('m')) {
  $now = date('h') . ":" . $min;
 } else {
  $now = "00:00";
 }
 for($i=0;$i<17;$i++) {
  if($i % 2 == 1) {
	  $odd = "bgcolor='#DDE7F2'";
  } else {
	  $odd = "bgcolor='#F8FAFC'";
  }
     if($now == $time[$i]) {
         echo "<tr><th scope='row' class='now'>" . $time[$i] . "</th><td " . $odd . ">This is the current time</td></tr>";
     } else {
         echo "<tr><th scope='row'>" . $time[$i] . "</th><td " . $odd . "> </td></tr>";
     }
 }
 ?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.