六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 217|回复: 0

js处理当前系统时间在给定的一个时间和给定时间的前一个月的时间段范围内

[复制链接]

升级  15.33%

21

主题

21

主题

21

主题

秀才

Rank: 2

积分
73
 楼主| 发表于 2013-1-29 08:52:24 | 显示全部楼层 |阅读模式
function renderer_Meta_notice(value, cellmeta, record){
    var now = new Date();
    var yy = now.getFullYear();//系统年份4位
    var mm = now.getMonth()+1;//系统月份
    var dd = now.getDate();//系统当前几号(1-31)
   
    var endtime = record.get("Meta_Contract_End_Date");//给定的时间
    var etyy='',etmm='',etdd='';//结束时间的年、月、日
    var styy='',stmm='',stdd='';//结束时间的前一个月的年、月、日
    if(endtime!=null && endtime!=''){
        endtime = endtime.substring(0,10);
        var arr = endtime.split('-');
        etyy = arr[0];
        etmm = arr[1];
        erdd = arr[2];
       
        stmm = etmm-1;
        if(stmm==0){
            styy=-1;
            stmm=12;
        }
        styy = styy+etyy;
        var new_date = new Date(styy,stmm,1);
        var theMouMaxDate = (new Date(new_date.getTime()-1000*60*60*24)).getDate();//获得当前给定时间前一个月的月份的日期最大值
        if(erdd>theMouMaxDate){
            stdd = theMouMaxDate;
        }else{
            stdd = erdd;
        }
        if(value==""){
            value="no_food.jpg";
        }
        if(yy>=styy && yy<=etyy){
            if(yy>styy && yy<etyy){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy==styy && mm>stmm && yy<etyy){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy==styy && mm==stmm && dd>stdd && yy<etyy){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy==styy && mm==stmm && dd==stdd && yy<etyy){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy>styy && yy==etyy && mm<etmm){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy>styy && yy==etyy && mm==etmm && dd<etdd){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else if(yy>styy && yy==etyy && mm==etmm && dd==etdd){
                return "<img src='/upload/"+value+"' width='20px' height='20px'/>";
            }else{
                return "";
            }
        }else{
            return "";
        }
        //alert(endtime+","+yy+"-"+mm+"-"+dd+","+styy+"-"+stmm+"-"+stdd);
    }
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表