The JQuery UI library’s Datepicker function is very convenient. Here’s a way to override the date field if you want to allow the user to also input the time of day along with it without adding an extra field and deal with merging the values in the backend. You can also add “+d.getSeconds()” if you want to allow seconds, but I find that’s wasted space.
$('.datepicker').datepicker({ dateFormat: 'yy-dd-mm', onSelect: function(datetext){ var d = new Date(); // current time datetext=datetext+" "+d.getHours()+":"+d.getMinutes(); $('.datepicker').val(datetext); }, });