代码之家  ›  专栏  ›  技术社区  ›  Bram

如何将值设置为每周的今天输入

  •  -2
  • Bram  · 技术社区  · 7 年前

    基本上如果我打字

    <input type="week">
    

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

    3 回复  |  直到 6 年前
        1
  •  4
  •   Bram    7 年前

    如果有其他人像我一样对此有问题,我会通过以下方法解决它,我不希望这样,因为人们只是拒绝投票新手,他们在表面上很难找到解决方案。

    <input type="week" value="<?php echo date('Y').'-W'.date('W');?>">

        2
  •  -1
  •   Rashid Ahmad Khan    7 年前

    您可以执行以下操作:

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

    有关更多信息,请单击此处 HTML5 input type=week

    See example here

    它将在最新的chrome&IE浏览器。

        3
  •  -1
  •   Bhagchandani Sougata Bose    7 年前

    链接 http://w3c.github.io/html-reference/input.week.html 将包含有关输入类型=“周”的所有详细信息。

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