从现在开始使用PHP,我怎样才能回复日期?

I am making a script that will allow admins to ban IPs. I am currently implementing the ban length system, however I am trying to echo the lift date next to each select option.

Here is my HTML for the dropdown select:

             <strong>Select Ban Length</strong>
       <div class="select-style">
  <select>
    <optgroup label="Temporary Ban Options">
    <option value="1">1 Day</option>
    <option value="3">3 Days</option>
    <option value="7">7 Days</option>
    <option value="14">14 Days</option>
    </optgroup>
    <optgroup label="Permanent Ban Options">
      <option value="PERMANENT">Permanent - Never Lift Ban</option>
    </optgroup>
  </select>
</div>

What I am asking is how can I echo the lift date next to each item? For example:

enter image description here

I have started with <?php echo date('Y-m-d H:i:s'); ?> to get the current date but how can I, as shown in the image above achieve something similar where the lift date is beside the ban length?

You would use strtotime's automatic + n days ability using this date string m-d-Y H:i A to give what you asked for in your example image.

<strong>Select Ban Length</strong>
<div class="select-style">
  <select>
    <optgroup label="Temporary Ban Options">
    <?php
    foreach (array(1, 3, 7, 14) as $d){
        // setting $date and $text separately just for readability here
        $text = $d . ' Day' . ($d===1? '': 's');
        $date = date('m-d-Y H:i A', strtotime('+ ' . $d .' days'));
        echo '<option value="'.$d.'">' . $text . ' (' . $date . ')</option>';
    }
    ?>
    </optgroup>
    <optgroup label="Permanent Ban Options">
      <option value="PERMANENT">Permanent - Never Lift Ban</option>
    </optgroup>
  </select>
</div>

Here is how you'd do it:

  <select>
    <optgroup label="Temporary Ban Options">
    <option value="1">1 Day (<?= date('Y-m-d H:i:s', strtotime("+1 day")) ?>)</option>
    <option value="3">3 Days (<?= date('Y-m-d H:i:s', strtotime("+3 days")) ?>)</option>
    <option value="7">7 Days (<?= date('Y-m-d H:i:s', strtotime("+7 days")) ?>)</option>
    <option value="14">14 Days (<?= date('Y-m-d H:i:s', strtotime("+14 days")) ?>)</option>
    </optgroup>
    <optgroup label="Permanent Ban Options">
      <option value="PERMANENT">Permanent - Never Lift Ban</option>
    </optgroup>
  </select>

Use similar code:

 echo date('Y-m-d H:i:s', strtotime("+1 day"))

In your case:

<option value="1">1 Day (<?= date('Y-m-d H:i:s', strtotime("+1 day")) ?>)</option>
    <option value="3">3 Days (<?= date('Y-m-d H:i:s', strtotime("+3 days")) ?>)</option>
    <option value="7">7 Days (<?= date('Y-m-d H:i:s', strtotime("+7 days")) ?>)</option>
    <option value="14">14 Days (<?= date('Y-m-d H:i:s', strtotime("+14 days")) ?>)</option>

Read more about strtotime function: http://www.w3schools.com/php/func_date_strtotime.asp