Title: Easyui Default date format to dd.mm.yyyy
Post by: Alfred on April 17, 2018, 10:34:26 AM
I found the following codes to override easyui default date format. Instead of using forward slash I want to use .(period) to separate the day, month and year. So I change the forwardslash with period(.). The problem is that I could not select the other dates other than the current date from the date pickup. $.extend($.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; //(d<10?('0'+d):d)+'.'+(m<10?('0'+m):m)+'.'+y; this works but would not allow me to choose other dates }, parser:function(s){ if (!s) return new Date(); var ss = s.split('/'); var d = parseInt(ss[0],10); var m = parseInt(ss[1],10); var y = parseInt(ss[2],10); if (!isNaN(y) && !isNaN(m) && !isNaN(d)){ return new Date(y,m-1,d); } else { return new Date(); } } }); I could not figure out what else must be changed in the codes to make it work. Thanks.
Title: Re: Easyui Default date format to dd.mm.yyyy
Post by: jarry on April 17, 2018, 06:30:02 PM
The code should be: $.extend($.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; }, parser:function(s){ if (!s) return new Date(); var ss = s.split('\.'); var d = parseInt(ss[0],10); var m = parseInt(ss[1],10); var y = parseInt(ss[2],10); if (!isNaN(y) && !isNaN(m) && !isNaN(d)){ return new Date(y,m-1,d); } else { return new Date(); } } });
Title: Re: Easyui Default date format to dd.mm.yyyy
Post by: Alfred on April 17, 2018, 08:11:42 PM
Thank very much, this works.
|