beachdaze Posted January 19, 2007 Share Posted January 19, 2007 n00bie here - Need to have an array that returns time in 30 minute increments from a start to stop time. Basically from 8 AM Thursday to 5 PM the following Sunday. I need it in a column and format such as Thursday, June 1, 2007 8:00 AM. Please help. If there is a turorial available just point the way!Peace,B Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 Check out strtotime() and date() Quote Link to comment Share on other sites More sharing options...
metrostars Posted January 19, 2007 Share Posted January 19, 2007 I know it's a bit messy, but this should work.[code]<?php$min = 0;do {$curdate = date('l, F d, Y h:i A', mktime(8, 0 + $min, 0, 01, 18, 2007));echo $curdate . "</br>";$min = $min + 30;$currentdate = mktime(8, 0 + $min, 0, 01, 18, 2007);$findate = mktime(17, 0, 0, 01, 21, 2007);} while ($currentdate <= $findate) ?>[/code]EDIT :- BETTER VERSION[code]<?php$min = 0;do {$curdate = mktime(8, 0 + $min, 0, 01, 18, 2007);echo date('l, F d, Y h:i A', $curdate) . "</br>";$findate = mktime(17, 0, 0, 01, 21, 2007);$min = $min + 30;} while ($curdate < $findate)?>[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 19, 2007 Share Posted January 19, 2007 Here's another solution, using just the strtotime() and date() functions:[code]<?php$start_time = strtotime('1/25/2007 8:00 AM');$end_time = strtotime('this sunday 5:00 PM',$start_time);for ($i = $start_time;$i<=$end_time;$i += 1800) // 1800 is the number of seconds in 30 minutes echo date('l, F j, Y g:i A',$i).'<br>';?>[/code]Ken Quote Link to comment 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.