开发者

select menu with current date

开发者 https://www.devze.com 2023-04-04 13:16 出处:网络
How do you create a select with the option of 2 days ahead from today picked as the default option (i.e. a 48 hour window) in PHP? This is the code I\'m using so far but it doesn\'t work unfortunately

How do you create a select with the option of 2 days ahead from today picked as the default option (i.e. a 48 hour window) in PHP? This is the code I'm using so far but it doesn't work unfortunately!

<?php
$weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$days = range (1, 31);
$currentDay = date('F');
echo "<select name='weekday'>";
foreach ($days as $value) {
  $default = ($value == $currentD开发者_如何转开发ay)?'selected="selected"':'';
  echo '<option '.$default.' value="'.$value.'">'.$value."</option>\n";
}
echo '</select> &nbsp; ';
?>


I'm confused as to what your code does.

As far as I can tell $weekday is not used after being instantiated, and you are setting $currentDay to the text representation of the current month (e.g. September).

But if you want to get the day of month of the day 48 hours from now:

$two_days_ahead = date('j', strtotime('+ 48 hours'));
0

精彩评论

暂无评论...
验证码 换一张
取 消