JS循环遍历时间/获取当前时间(年-月-日 时:分:秒)

<span class="tm" style="margin-right: 10px; float:right">
        ${content.releasetime?string("yy-MM-dd")}
    </span>
    
    function time(){
        for(var i = 0; i<3; i++){
            var d1 = $(".tm").eq(i).text();
            var d1 = "20"+d1;    
            d1 = d1.replace(/-/g,"/");        
            d1= new Date(d1);            
            var d2= new Date(d1);
            d2.setDate(d1.getDate()+3);
            if(d2 < today){                
                $(".sjnew:eq("+i+")").hide();//隐藏标签里面的内容            
            }
        }
    }

获取当前时间(年-月-日 时:分:秒)

function getNowFormatDate() { 
            var now = new Date();        
            var year = now.getFullYear();       //年
            var month = now.getMonth() + 1;     //月
            var day = now.getDate();            //日        
            var hh = now.getHours();            //时
            var mm = now.getMinutes();          //分
            var ss = now.getSeconds();           //秒        
            var clock = year + "-";        
            if(month < 10)
                    clock += "0";       
            clock += month + "-";        
            if(day < 10)
                    clock += "0";            
            clock += day + " ";        
            if(hh < 10)
                    clock += "0";            
            clock += hh + ":";
            if (mm < 10) clock += '0'; 
            clock += mm + ":";          
            if (ss < 10) clock += '0'; 
            clock += ss; 
            return(clock); 
        } 

猜你喜欢

转载自blog.csdn.net/qq_39150358/article/details/81280383
今日推荐