<tfoot id='p1ziS'></tfoot>

        <bdo id='p1ziS'></bdo><ul id='p1ziS'></ul>

      <small id='p1ziS'></small><noframes id='p1ziS'>

        <i id='p1ziS'><tr id='p1ziS'><dt id='p1ziS'><q id='p1ziS'><span id='p1ziS'><b id='p1ziS'><form id='p1ziS'><ins id='p1ziS'></ins><ul id='p1ziS'></ul><sub id='p1ziS'></sub></form><legend id='p1ziS'></legend><bdo id='p1ziS'><pre id='p1ziS'><center id='p1ziS'></center></pre></bdo></b><th id='p1ziS'></th></span></q></dt></tr></i><div id='p1ziS'><tfoot id='p1ziS'></tfoot><dl id='p1ziS'><fieldset id='p1ziS'></fieldset></dl></div>
      1. <legend id='p1ziS'><style id='p1ziS'><dir id='p1ziS'><q id='p1ziS'></q></dir></style></legend>

        从 PHP 中的输入表单获取日期

        时间:2023-10-12

            <tbody id='RlHLb'></tbody>
          <tfoot id='RlHLb'></tfoot>

            <i id='RlHLb'><tr id='RlHLb'><dt id='RlHLb'><q id='RlHLb'><span id='RlHLb'><b id='RlHLb'><form id='RlHLb'><ins id='RlHLb'></ins><ul id='RlHLb'></ul><sub id='RlHLb'></sub></form><legend id='RlHLb'></legend><bdo id='RlHLb'><pre id='RlHLb'><center id='RlHLb'></center></pre></bdo></b><th id='RlHLb'></th></span></q></dt></tr></i><div id='RlHLb'><tfoot id='RlHLb'></tfoot><dl id='RlHLb'><fieldset id='RlHLb'></fieldset></dl></div>
          • <small id='RlHLb'></small><noframes id='RlHLb'>

              <bdo id='RlHLb'></bdo><ul id='RlHLb'></ul>

                  <legend id='RlHLb'><style id='RlHLb'><dir id='RlHLb'><q id='RlHLb'></q></dir></style></legend>
                • 本文介绍了从 PHP 中的输入表单获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试从日期输入表单中检索日期,但无法正常工作.我现在使用的代码只返回一个错误和这个日期:1970-01-01.这是不正确的,我想知道如何解决这个问题.这将在稍后用于查询数据库表.我希望日期基本上只是一个具有以下格式的字符串:yyyy-mm-dd"

                  I'm trying to retrieve a date from a date input form and I just can't get it to work properly. The code I'm using now only returns an error and this date: 1970-01-01. That is not correct and I would like to know how I can approach this. This will be used later to query a database table. I want the date to be basically just a string with this format: "yyyy-mm-dd"

                  代码:

                  HTML

                  <form name="DateFilter" method="POST">
                  From:
                  <input type="date" name="dateFrom" value="<?php echo date('Y-m-d'); ?>" />
                  <br/>
                  To:
                  <input type="date" name="dateTo" value="<?php echo date('Y-m-d'); ?>" />
                  </form>
                  

                  PHP

                  $new_date = date('Y-m-d', strtotime($_POST['dateFrom']));
                  echo $new_date;
                  

                  提前致谢,

                  ~现实

                  ~~~ 编辑~~~

                  为任何想知道它是如何完成的人提供的固定解决方案:

                  HTML

                  <form name="Filter" method="POST">
                      From:
                      <input type="date" name="dateFrom" value="<?php echo date('Y-m-d'); ?>" />
                      <br/>
                      To:
                      <input type="date" name="dateTo" value="<?php echo date('Y-m-d'); ?>" />
                      <input type="submit" name="submit" value="Login"/>
                  </form>
                  

                  PHP

                  $new_date = date('Y-m-d', strtotime($_POST['dateFrom']));
                  echo $new_date;
                  

                  特别感谢每一个回答.

                  推荐答案

                  验证输入.

                  $time = strtotime($_POST['dateFrom']);
                  if ($time) {
                    $new_date = date('Y-m-d', $time);
                    echo $new_date;
                  } else {
                     echo 'Invalid Date: ' . $_POST['dateFrom'];
                    // fix it.
                  }
                  

                  这篇关于从 PHP 中的输入表单获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如果未选择日期,如何防止 bootstrap-datepicker 从输入中清除现有值? 下一篇:如何使用 datepicker、ajax、php、mysql 在两个日期之间生成报告?

                  相关文章

                  • <bdo id='K8qwQ'></bdo><ul id='K8qwQ'></ul>

                  <small id='K8qwQ'></small><noframes id='K8qwQ'>

                  <i id='K8qwQ'><tr id='K8qwQ'><dt id='K8qwQ'><q id='K8qwQ'><span id='K8qwQ'><b id='K8qwQ'><form id='K8qwQ'><ins id='K8qwQ'></ins><ul id='K8qwQ'></ul><sub id='K8qwQ'></sub></form><legend id='K8qwQ'></legend><bdo id='K8qwQ'><pre id='K8qwQ'><center id='K8qwQ'></center></pre></bdo></b><th id='K8qwQ'></th></span></q></dt></tr></i><div id='K8qwQ'><tfoot id='K8qwQ'></tfoot><dl id='K8qwQ'><fieldset id='K8qwQ'></fieldset></dl></div>

                • <tfoot id='K8qwQ'></tfoot>

                    <legend id='K8qwQ'><style id='K8qwQ'><dir id='K8qwQ'><q id='K8qwQ'></q></dir></style></legend>