最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Preset current date and time in input type "datetime" using php - Stack Overflow

programmeradmin0浏览0评论

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..

What I want...

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..

What I want...

Share Improve this question edited Oct 27, 2017 at 10:06 Shujaat Shaikh asked Oct 27, 2017 at 9:13 Shujaat ShaikhShujaat Shaikh 2991 gold badge6 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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/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'); ?>">
发布评论

评论列表(0)

  1. 暂无评论