neilfurry Posted May 12, 2012 Share Posted May 12, 2012 Hello, Can anyone help me with my code? here is my snippet: <? $start = date('g:i A',strtotime(0)); $end = date('g:i A',strtotime(24)); for($a=$start; $a<$end; $a++){ echo $a; } I want to display the time from 12:00AM - 11:00PM in vertical format.. how can i do this? Thank you in advance ?> Quote Link to comment https://forums.phpfreaks.com/topic/262455-time-loop/ Share on other sites More sharing options...
ManiacDan Posted May 12, 2012 Share Posted May 12, 2012 Not a line of this code is correct, so let's just ignore it and start over. You're looking for something like this? 12:00 AM 12:01 AM 12:02 AM //etc. 10:58 PM 10:59 PM 11:00 PM Quote Link to comment https://forums.phpfreaks.com/topic/262455-time-loop/#findComment-1345021 Share on other sites More sharing options...
neilfurry Posted May 12, 2012 Author Share Posted May 12, 2012 what i want to display is the 1 hour format and not with :01, :02, :03 etc...al i want is to display time like this: 12:00AM 1:00AM 2:00AM . . . 11:00PM using loops, how can i do this... i think there is small changes i need to get done on my script i posted here.. please help.. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/262455-time-loop/#findComment-1345023 Share on other sites More sharing options...
.josh Posted May 12, 2012 Share Posted May 12, 2012 for ($c = 0;$c<24;$c++) { echo date('g:00 A',strtotime("+$c hour",mktime(0))) . "<br/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/262455-time-loop/#findComment-1345031 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.