Jump to content

php date/time


karimali831

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/210333-php-datetime/
Share on other sites

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>';

Link to comment
https://forums.phpfreaks.com/topic/210333-php-datetime/#findComment-1097616
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.