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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.