How to get complete(include hour,minute and seconds) date format of datepicker value in javascript
16,717
You can use DateTimePicker to specify the dateFormat and timeFormat something like this :
$('#datepicker').datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "hh:mm:ss"
});
Or else you can try adding get method like :
$(function() {
$('#datepicker').datepicker({
dateFormat: 'D M dd yy',
onSelect: function(datetext){
var d = new Date(); // for now
datetext=datetext+" "+d.getHours()+": "+d.getMinutes()+": "+d.getSeconds();
$('#datepicker').val(datetext);
},
});
});
Check fiddle : http://jsfiddle.net/5qkt8e06/62/
Author by
Bibin James
Updated on July 14, 2022Comments
-
Bibin James almost 2 years
I am using the UI DatePicker from jQuery UI as the stand alone picker.. i have this code
<div id="datepicker"></div>
And the follow JS
$('#datepicker').datepicker();
When i try to return the value with this code:
var date = $('#datepicker').datepicker('getDate');
I am returned this...
Sun Nov 01 2015 00:00:00 GMT+0530 (India Standard Time)
Which is totally the wrong format... Is there a way i can get the format like
Sun Nov 01 2015 05:30:00 GMT+0530 (India Standard Time)
??