karimali831 Posted August 10, 2010 Share Posted August 10, 2010 Hi! The below dropdown will show dates/times every 15 minutes from 12am to 11:45pm for only 1 day. I want it to show for 5 days, anyway I can do this? Below code: $start = strtotime('12:00am'); $end = strtotime('11:45pm'); echo '<select name="time">'; for ($i = $start; $i <= $end; $i += 900) { echo '<option>' . date('F j, Y, \a\t g:i a', $i); } echo '</select>'; Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/210333-php-datetime/ Share on other sites More sharing options...
AbraCadaver Posted August 10, 2010 Share Posted August 10, 2010 $end = strtotime('11:45pm +5 days'); Quote Link to comment https://forums.phpfreaks.com/topic/210333-php-datetime/#findComment-1097615 Share on other sites More sharing options...
MadTechie Posted August 10, 2010 Share Posted August 10, 2010 LOL@ $end = strtotime('11:45pm +5 days'); Just do another loop of 5 ie echo '<select name="time">'; for ($d = 0; $d < 5; $d++){ $start = strtotime('12:00am'); $end = strtotime('11:45pm'); for ($i = $start; $i <= $end; $i += 900){ echo '<option>' . date('F j, Y, \a\t g:i a', $i+($d*24*60*60)); } } echo '</select>'; Quote Link to comment https://forums.phpfreaks.com/topic/210333-php-datetime/#findComment-1097616 Share on other sites More sharing options...
AbraCadaver Posted August 10, 2010 Share Posted August 10, 2010 LOL@ $end = strtotime('11:45pm +5 days'); Why is that funny? Better than doing another loop. Quote Link to comment https://forums.phpfreaks.com/topic/210333-php-datetime/#findComment-1097619 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.