I have to set the date in my datepicker in dd/mm/yyyy format. Whet I'm trying to do, with Javascript is this:
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);
the problem is that the value inside my datepicker is always in format mm/dd/yyyy. Where is the problem??
Here the definition datepicker and datepicker options:
<div class="input-group date"> <asp:TextBox runat="server" ID="txtDataOrdine" class="form-control" onBlur="CalcolaTotaliTestata('txtDataOrdine')"></asp:TextBox> <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i>/span> </div> <script type="text/javascript"> $('.input-group.date').datepicker({ todayBtn: "linked", language: "it", autoclose: true, todayHighlight: true, dateFormat: 'dd/mm/yyyy' }); </script>
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);
Here's one specific for your code: var date = $('#datepicker'). datepicker({ dateFormat: 'dd-mm-yy' }). val();
Change
dateFormat: 'dd/mm/yyyy'
to
format: 'dd/mm/yyyy'
Looks like you just misread some documentation!
Changing to format: 'dd/mm/yyyy'
didn't work for me, and changing that to dateFormat: 'dd/mm/yyyy'
added year multiple times, The finest one for me was,
dateFormat: 'dd/mm/yy'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With