Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change date format (MM/DD/YY) to (YYYY-MM-DD) in date picker

I have following datepicker script:

<script>  $(function(){         $("#to").datepicker();         $("#from").datepicker().bind("change",function(){             var minValue = $(this).val();             minValue = $.datepicker.parseDate("mm/dd/yy", minValue);             minValue.setDate(minValue.getDate()+1);             $("#to").datepicker( "option", "minDate", minValue );         })     }); </script>  

Now dateformat is MM/DD/YY .how to change the date format to YYYY-MM-DD?

like image 875
John Ken Avatar asked Sep 21 '11 12:09

John Ken


People also ask

How do I change Datepicker format from DD MM to YYYY?

var year = 2014; var month = 5; var day = 10; var realDate = new Date(year, month - 1, day); // months are 0-based! $('#MainContent_txtDataConsegna'). datepicker({ dateFormat: 'dd/mm/yyyy' }); // format to show $('#MainContent_txtDataConsegna'). datepicker('setDate', realDate);

How do I change the Datepicker format to yyyy mm dd in HTML?

$("#from-datepicker"). datepicker({ dateFormat: 'yy-mm-dd'}); $("#from-datepicker"). on("change", function () { var fromdate = $(this). val(); alert(fromdate); });

How do I change date picker control?

Click the Date Picker Control in the Controls group. Click Properties in the Controls group. Click inside the Title text box and enter End Date:. In the Display The Date Like This list box, select the desired date format and then click OK.


1 Answers

Use the dateFormat option

 $(function(){         $("#to").datepicker({ dateFormat: 'yy-mm-dd' });         $("#from").datepicker({ dateFormat: 'yy-mm-dd' }).bind("change",function(){             var minValue = $(this).val();             minValue = $.datepicker.parseDate("yy-mm-dd", minValue);             minValue.setDate(minValue.getDate()+1);             $("#to").datepicker( "option", "minDate", minValue );         })     }); 

Demo at http://jsfiddle.net/gaby/WArtA/

like image 72
Gabriele Petrioli Avatar answered Sep 21 '22 19:09

Gabriele Petrioli