简体   繁体   English

如何从当前日期设置输入字段的最大日期

[英]How to set input field's max date from current date

 <input type="date" name="date" min=
     <?php
         echo date('Y-m-d');
     ?>
 >

I want users to select a date between current date to next 7 days.我希望用户 select 从当前日期到下一个 7 天之间的日期。 This input min disables past dates from current date.此输入最小值禁用当前日期的过去日期。 Now how can I set the max limit next 7 days from current date?现在如何设置从当前日期开始接下来 7 天的最大限制?

You can try adding the max attribute to the input but be aware that this can be modified in the browser.您可以尝试将max属性添加到输入中,但请注意,这可以在浏览器中进行修改。

<input type="date" name="date" min="<?=date('Y-m-d');?>" max="<?=date('Y-m-d',strtotime('now +1 week'));?>" />

You could try by adding:您可以尝试添加:

max=
 <?php
     echo date('Y-m-d', strtotime('+7 days'));
 ?>

? ?

Increase days to php current Date() 将天数增加到 php 当前日期()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM