EasyUI Forum

General Category => Bug Report => Topic started by: ryan on May 09, 2012, 07:56:37 AM



Title: date format on the popup
Post by: ryan on May 09, 2012, 07:56:37 AM
how to format the current date code edit data on a popup to fit with what we want ?  ???
example


I want the date format when edited as below



Title: Re: date format on the popup
Post by: stworthy on May 09, 2012, 07:34:31 PM
It is the problem to set your date format to 'm-d-y'. Please override the 'formatter' and 'parser' of datebox:
Code:
$.fn.datebox.defaults.formatter = function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return (m<10?('0'+m):m)+'-'+(d<10?('0'+d):d)+'-'+y;
};
$.fn.datebox.defaults.parser = function(s){
if (!s) return new Date();
var ss = s.split('-');
var m = parseInt(ss[0],10);
var d = 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: date format on the popup
Post by: ryan on May 10, 2012, 03:38:44 AM
code run on the calendar but not change when popup appear when editing formatted data from the database remains y-m-d