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 Link to comment https://forums.phpfreaks.com/topic/34895-array-question/ Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 Check out strtotime() and date() Link to comment https://forums.phpfreaks.com/topic/34895-array-question/#findComment-164524 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] Link to comment https://forums.phpfreaks.com/topic/34895-array-question/#findComment-164538 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 Link to comment https://forums.phpfreaks.com/topic/34895-array-question/#findComment-164564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.