easyui单行变色加js字符串转换时间类

 //单行变色
            rowStyler: function (value, row, index) {
                //var date = new Date();
                //var year = date.getFullYear();
                //var month = date.getMonth() + 1;
                //var day = date.getDate();
                //var hour = date.getHours();
                //var minute = date.getMinutes();
                //var second = date.getSeconds();
                //var mydatee = year + '/' + (month - 4) + '/' + day + ' ' + hour + ':' + minute + ':' + second;
                把字符串格式转化为日期类
                //if (value.up_time) {
                //    value.up_time = value.up_time.replace(/-/g, "/");
                //}
                //value.up_time = value.up_time.parseInt(value.up_time);
                //进行比较
                //var time2 = new Date().Format("yyyy/MM/dd hh:mm:ss");
                //var yy = time2.parseInt(time2);
                //console.log("格式化的时间" + time2);
                //time2 = time2.replace(/-/g, "/");
                //console.log("我的时间" + mydatee);
                if (value.up_time === '' || value.up_time === undefined || value.up_time === null) {
                    return 'background-color:#ff9966;color:blue;';
                } else {
                    //当前时间减掉5个月还大于更新时间
                    //console.log("我的时间" + mydatee);
                    var datett = new Date();//获取当前时间
                    var shi = datett.getFullYear();//获取当前时间年
                    var datat = parseInt(datett.getMonth() + 1 - 4);//获取当前时间月and减掉4个月,月从0开始所以加1
                    if (datat <= 0) {//如果当前时间月减掉4个月小于等于0
                        shi = datett.getFullYear() - 1;//当前时间年减1
                        if (datat == 0) {//如果当前时间月减掉的4个月等于0
                            datat = 12;//那么当前月等于12
                        } else {
                            datat = parseInt(12 - Math.abs(datat));//当前时间月等于n=12-(6+1-4),绝对值
                        }
                    }
                    var qq = shi + '/' + datat + '/' + datett.getDate() + ' ' + datett.getHours() + ':' + datett.getMinutes() + ':' + datett.getSeconds() + '.000';
                    var timestamp1 = parseInt(new Date(qq).getTime() / 1000);    // 当前时间戳
                    var date = value.up_time;//得到更新时间
                    //date = date.substring(0, 19);
                    date = date.replace(/-/g, '/');//正则替换斜杠
                    var timestamp2 = parseInt(new Date(date).getTime() / 1000); //更新时间时间戳
                    if (timestamp2 > timestamp1) {
                        //console.log("11111的时间" + yy);
                        //console.log("66666更新的时间" + value.up_time);
                        //return 'background-color:#ff9966;color:blue;';
                    } else {
                        //console.log("大家的时间" + yy);
                        //console.log("大家更新的时间" + value.up_time);
                        return 'background-color:#ff0016;color:blue;';
                    }
                }
            },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值