`
刘金剑
  • 浏览: 144694 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

    博客分类:
  • JS
阅读更多

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);
    }

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics