Reputation: 299
How can I preset the value in datetime input to current date and time using php or javascript?
<input type="datetime-local" name="followupon">
Upvotes: 0
Views: 4190
Reputation: 2622
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'); ?>">
Upvotes: 6