LigerUi中Grid控件中的日期列的日期转换技巧(示例源代码)

保存问题
在 grid.bind('afterSubmitEdit', function (e) { //之后调用时间转换方法


e.newdata.时间变量= Todate(e.newdata.时间变量)
...
...
....
}
//保存进行时间格式的转换
function Todate(num){
//Fri Oct 31 18:00:00 UTC+0800 2008
num = num + ""; //给字符串后就一个空格
var date = "";
var month = new Array();
month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4;
month["May"] = 5; month["Jan"] = 6; month["Jul"] = 7; month["Aug"] = 8;
month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
var week = new Array();
week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四";
week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
str = num.split(" "); //根据空格组成数组
date = str[5] + "-"; //就是在2008的后面加一个“-”
//通过修改这里可以得到你想要的格式
date = date + month[str[1]] + "-" + str[2] + " " + str[3];
//date=date+" 周"+week[str[0]];
return date;
}
保存问题
在 grid.bind('afterSubmitEdit', function (e) { //之后调用时间转换方法
   
     
      e.newdata.时间变量= Todate(e.newdata.时间变量)
...
...
....
}
//保存进行时间格式的转换
function Todate(num){
      //Fri Oct 31 18:00:00 UTC+0800 2008 
      num = num + ""; //给字符串后就一个空格
      var date = "";
      var month = new Array();
      month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4;
      month["May"] = 5; month["Jan"] = 6; month["Jul"] = 7; month["Aug"] = 8;
      month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
      var week = new Array();
      week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四";
      week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
      str = num.split(" "); //根据空格组成数组
      date = str[5] + "-"; //就是在2008的后面加一个“-”
      //通过修改这里可以得到你想要的格式
      date = date + month[str[1]] + "-" + str[2] + " " + str[3];
      //date=date+" 周"+week[str[0]];
      return date;
  }
 

你可能感兴趣的:(grid)