How do I format date in jQuery datetimepicker?

Here you go. $(‘#timePicker’).datetimepicker({ // dateFormat: ‘dd-mm-yy’, format:’DD/MM/YYYY HH:mm:ss’, minDate: getFormattedDate(new Date()) }); function getFormattedDate(date) { var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getFullYear().toString().slice(2); return day + ‘-‘ + month + ‘-‘ + year; } You need to pass datepicker() the date formatted correctly.

jQuery Date Picker – disable past dates

You must create a new date object and set it as minDate when you initialize the datepickers <label for=”from”>From</label> <input type=”text” id=”from” name=”from”/> <label for=”to”>to</label> <input type=”text” id=”to” name=”to”/> var dateToday = new Date(); var dates = $(“#from, #to”).datepicker({ defaultDate: “+1w”, changeMonth: true, numberOfMonths: 3, minDate: dateToday, onSelect: function(selectedDate) { var option = this.id == … Read more

Remove Datepicker Function dynamically

You can try the enable/disable methods instead of using the option method: $(“#txtSearch”).datepicker(“enable”); $(“#txtSearch”).datepicker(“disable”); This disables the entire textbox. So may be you can use datepicker.destroy() instead: $(document).ready(function() { $(“#ddlSearchType”).change(function() { if ($(this).val() == “Required Date” || $(this).val() == “Submitted Date”) { $(“#txtSearch”).datepicker(); } else { $(“#txtSearch”).datepicker(“destroy”); } }).change(); }); Demo here.

How to make jqueryUI datepicker submit in a different format than what is being displayed?

There’s 2 configuration options for that: altField and altFormat. http://api.jqueryui.com/datepicker/#option-altField If you specify an altField, that field will be updated too, and will have the altFormat. Normally you will want make the altField a hidden field, soyou can ignore the regular field and send to db the altField.

jQuery datepicker- 2 inputs/textboxes and restricting range

Many thanks for your help Ben, I have built upon your posts and have come up with this. It is now complete and works brilliantly! Here’s a Working Demo. Add /edit to the URL to see the code Complete Code below- $(function () { $(‘#txtStartDate, #txtEndDate’).datepicker({ showOn: “both”, beforeShow: customRange, dateFormat: “dd M yy”, firstDay: … Read more

jQuery-UI datepicker default date

Try passing in a Date object instead. I can’t see why it doesn’t work in the format you have entered: <script type=”text/javascript”> $(function() { $(“#birthdate” ).datepicker({ changeMonth: true, changeYear: true, yearRange: ‘1920:2010’, dateFormat : ‘dd-mm-yy’, defaultDate: new Date(1985, 00, 01) }); }); </script> http://api.jqueryui.com/datepicker/#option-defaultDate Specify either an actual date via a Date object or as … Read more

Setting min date in jQuery datepicker

$(function () { $(‘#datepicker’).datepicker({ dateFormat: ‘yy-mm-dd’, showButtonPanel: true, changeMonth: true, changeYear: true, yearRange: ‘1999:2012’, showOn: “button”, buttonImage: “images/calendar.gif”, buttonImageOnly: true, minDate: new Date(1999, 10 – 1, 25), maxDate: ‘+30Y’, inline: true }); }); Just added year range option. It should solve the problem

How to format date with hours, minutes and seconds when using jQuery UI Datepicker?

Try this fiddle $(function() { $(‘#datepicker’).datepicker({ dateFormat: ‘yy-dd-mm’, onSelect: function(datetext) { var d = new Date(); // for now var h = d.getHours(); h = (h < 10) ? (“0” + h) : h ; var m = d.getMinutes(); m = (m < 10) ? (“0” + m) : m ; var s = d.getSeconds(); … Read more