如何将值过帐到输入框中? [英] How I can POST the value into input box?

查看:67
本文介绍了如何将值过帐到输入框中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介

我想在单击 click 并将其后的值发布到输入(文本)框中后获取当前时间.

I would like to get the current time after clicking at click and POST the value into input (text)box.

注意

假设其中包含引导程序样式表.

Assume that bootstrap style sheet included.

[input box] 点击

Date.php

<form action="getTime.php" method="post">
      Date:&nbsp<input type="text" name="datetime" required>
                <button style="font-size:1em" type="submit" name="click" class="btn btn-info">click</button>
</form>

getTime.php

  if(isset($_POST['click']))
      {
          date_default_timezone_set('xxx/xxx); <!--xxx=any timezone-->
          $date = date('Y-m-d H:i:s');
          //debugging
          //echo $date;
      }

预期结果

[CURRENT TIME] 单击->单击单击

推荐答案

请尝试以下代码.可能会对您有帮助.

Please try the below code. It may help you.

if(isset($_POST["submit"]) || isset($_POST["submit_x"]))   {
    $new_date = date('Y-m-d', strtotime($_POST['datetime']));
 echo $new_date;
}

这篇关于如何将值过帐到输入框中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆