douhuitan5863 2017-10-27 09:13
浏览 122
已采纳

使用php在输入类型“datetime”中预设当前日期和时间

How can I preset the value in datetime input to current date and time using php or javascript?

<input type="datetime-local" name="followupon">

What I have.. enter image description here

What I want... **enter image description here**

  • 写回答

1条回答 默认 最新

  • doujiao2443 2017-10-27 10:01
    关注

    Well.. You can just set the value by using the "value" attribute:

    <input type="datetime-local" name="followupon" value="2014-01-02T11:42:13.510">
    

    See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#Value for more information

    If you want to use the current date, you can use php like so:

    <input type="datetime-local" name="followupon" value=<?php echo date('Y-m-d\TH:i:s'); ?>">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?