Display hours in select box with am/pm using php

Display hours in select box with am/pm using php

Select Hour :-
<select name="starthour" style="padding:5px;">
    <?php
      date_default_timezone_set('Asia/Kolkata');
      $currentDateTime=date('m/d/Y H:i:s');
      $curtime = date('H', strtotime($currentDateTime));
      $starttime = 00;
      $endtime = 23;
      $endloop = ($starttime + $endtime);
      for($hour = $starttime; $hour <=  $endloop ; $hour ++ )
      {
          $showtime = $hour.':00:00';
      ?>
      <option value="<?php echo $hour; ?>" <?php if($curtime == $hour) echo "selected='selected'" ?>><?php echo date('h A', strtotime($showtime)); ?></option>
      <?php
      }
    ?>   
</select>

Comments

Popular posts from this blog

Login with facebook using coldfusion

Create CSV file in Coldfusion Using CFFile

Get Previous One Day Data in Sql Server