EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: ikaurov on November 04, 2013, 10:33:23 PM



Title: datebox's calendar shows wrong date
Post by: ikaurov on November 04, 2013, 10:33:23 PM
Hello All !

I would like to display date in datebox as "dd.mm.yyyy" .

It works fine until I call calendar: "01.11.2013" becomes 11th January instead of 1st of November.
Please advise what am I miss.
Thanks, Ilya


Title: Re: datebox's calendar shows wrong date
Post by: acreonte82 on November 05, 2013, 01:24:18 AM
Post your code...


Title: Re: datebox's calendar shows wrong date
Post by: ikaurov on November 05, 2013, 02:09:02 AM

Code:
<input id="f_d1" type="text" class="easyui-datebox" value="01.11.2013">

<script>
$.fn.datebox.defaults.formatter = function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return (d<10?('0'+d):d)+'.'+(m<10?('0'+m):m)+'.'+y;
}
</script>


Title: Re: datebox's calendar shows wrong date
Post by: ikaurov on November 07, 2013, 01:00:26 AM
For what it worst, I end up with writing function set_calendar which move calendar to right date
at start  and each time when calendar is picked
Code:

$('#dd').datebox({
onSelect: function(date){
set_calendar(date.getFullYear(), date.getMonth(), date.getDate());
}
});

function set_calendar(y, m, d) {
     var el = $('#dd').datebox('calendar');
     el.calendar('moveTo', new Date(y, m, d));
}