js获取几天后的日期,获取当前月最后一天

function date2str(n) {
		var s, d, t, t2;
		t = new Date().getTime();
	    t2 = n * 1000 * 3600 * 24;
	    t+= t2;
	    d = new Date(t);
	    s = d.getUTCFullYear() + "-";
	    s += ("00"+(d.getUTCMonth()+1)).slice(-2) + "-";
	    s += ("00"+d.getUTCDate()).slice(-2);
	    return s;
	}
	
	function getCurrentMonthEndDate() {
        var dt = new Date();  
        dt.setDate(1);  
        dt.setMonth(dt.getMonth()+1);  
        cdt = new Date(dt.getTime()-1000*60*60*24);  
        
        s = cdt.getUTCFullYear() + "-";
	    s += ("00"+(cdt.getUTCMonth()+1)).slice(-2) + "-";
	    s += ("00"+cdt.getUTCDate()).slice(-2);
	    
	    return s;	      
	}

 

你可能感兴趣的:(js)