关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

EasyUI日期格式化(JS日期格式化)

发布时间:2019-11-09 08:58:07
{
  title: '出生日期', field: 'birthday', sortable: true, width: 100,
  formatter: function (value, row, index)
  {
  return new Date(row.birthday).Format("yyyy-MM-dd"); //格式化实现
  },
  hidden: false
 },
//函数
//js日期格式化函数
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
//调用: 
//var time1 = new Date().Format("yyyy-MM-dd");
//var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");



/template/Home/Zkeys/PC/Static