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

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

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'); ?>">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745340149a4623288.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信