【问题标题】:How to set the value to today of a week input如何将值设置为一周中的今天输入
【发布时间】:2018-02-23 04:07:43
【问题描述】:

基本上如果我输入了

<input type="week">

我应该输入什么来将默认值设置为今天的星期?

【问题讨论】:

标签: html input default-value


【解决方案1】:

如果其他人像我这样遇到问题,我会通过以下方式修复它,我不希望这是因为人们只是对那些在表面上找不到解决方案有困难的初学者投了反对票。

&lt;input type="week" value="&lt;?php echo date('Y').'-W'.date('W');?&gt;"&gt;

【讨论】:

    【解决方案2】:

    你可以这样做:

    <input type="week" name="year_weeks" value="2017-W20">
    

    更多信息请点击这里HTML5 input type=week

    See example here

    它适用于最新的 chrome 和 IE 浏览器。

    【讨论】:

      【解决方案3】:

      链接http://w3c.github.io/html-reference/input.week.html 将包含有关 input type="week" 的所有详细信息。

       <input type="week" name="year_week" value="2017-W42">
      

      【讨论】:

      • 请为发布的答案添加解释
      • 2017 年定义年份,前缀 -w 将定义周数。
      猜你喜欢
      • 1970-01-01
      • 2011-10-22
      • 1970-01-01
      • 2014-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      相关资源
      最近更新 更多