Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make a select list of time from 00:00 to 23:55 without DST?
    text
    copied!<p>I am trying to create two select lists both filled with the same times. It's basically for the user to select a start time and end time. I've calculated these as my times:</p> <pre><code>$startTime = 0; //00:00 $endTime = 86100; //23:55' $now = $startTime; </code></pre> <p>and then I'm incrementing like this:</p> <pre><code>$now += 300; </code></pre> <p>where 300 = 5 minutes, therefore I'm incrementing the time by 5 minutes during each loop.</p> <p>Therefore, my select lists should look like this:</p> <pre><code>00:00 00:05 00:10 ... ... 23:45 23:50 23:55 </code></pre> <p>The whole thing works, apart from the actual times being printed. I am getting this:</p> <pre><code>1:00 1:05 ... ... 00:45 00:50 00:55 </code></pre> <p>I suspect the problem is the fact we are now in Daylight Saving Time here in the UK. How should I therefore tackle this problem?</p> <p>This is my actual method:</p> <pre><code>public function timeSelectList() { $startTime = 0; //00:00 $endTime = 86100; //23:55' $now = $startTime; $startSelectList = '&lt;label for="startSelect"&gt;Start Time&lt;/label&gt;&lt;select name="startSelect" id="startSelect"&gt;'; $endSelectList = '&lt;label for="endSelect"&gt;End Time&lt;/label&gt;&lt;select name="endSelect" id="endSelect"&gt;'; while($now &lt;= $endTime) { if($now == 61200)//17:00 { $startSelectList .= '&lt;option value="'.$now.'" selected="selected"&gt;'.date('H:i', $now).'&lt;/option&gt;'; $endSelectList .= '&lt;option value="'.$now.'"&gt;'.date('H:i', $now).'&lt;/option&gt;'; } else if($now == 64800)//18:00 { $startSelectList .= '&lt;option value="'.$now.'"&gt;'.date('H:i', $now).'&lt;/option&gt;'; $endSelectList .= '&lt;option value="'.$now.'" selected="selected"&gt;'.date('H:i', $now).'&lt;/option&gt;'; } else { $startSelectList .= '&lt;option value="'.$now.'"&gt;'.date('H:i', $now).'&lt;/option&gt;'; $endSelectList .= '&lt;option value="'.$now.'"&gt;'.date('H:i', $now).'&lt;/option&gt;'; } $now += 300; //increment 5 minutes (300 seconds = 5 minutes } $startSelectList .= '&lt;/select&gt;'; $endSelectList .= '&lt;/select&gt;'; return $startSelectList.$endSelectList; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload