mraza Posted March 22, 2011 Share Posted March 22, 2011 hi , how can i display time in a row which start from 6 in morning untell next day morning.. 6.00 - 7.00 7.00 - 8.00 .... ..... and so on until next day 5.00-6.00 i tried this but i hope there is more effectives way and would loop until next day for 24 hours. <?php for($i=8;$i<=23;$i++) {?> <tr> <td><?php echo $i;?>.00-<?php echo $i+1;?>.00</td> </tr> <?php } ?> <?php for($i=0;$i<=7;$i++) {?> <tr> <td><?php echo $i;?>.00-<?php echo $i+1;?>.00</td> </tr> <?php } ?> thanks for any help Link to comment https://forums.phpfreaks.com/topic/231436-dislay-time-in-a-row/ Share on other sites More sharing options...
mikecampbell Posted March 22, 2011 Share Posted March 22, 2011 Using the modulus operator like such might help you... <?php for($i=0;$i<=23;$i++) { $hour1 = ($i+6)%24; $hour2 = ($i+7)%24; ?> <tr> <td><?php echo $hour1;?>.00-<?php echo $hour2;?>.00</td> </tr> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/231436-dislay-time-in-a-row/#findComment-1191067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.