js脚本 天数计算 大全

function now_week_monday()//这个星期的星期一
{
	var myDate = new Date();
	myDate.setDate( myDate.getDate() -myDate.getDay()+1 );  
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("这个星期的星期一"+firstDay);
	return firstDay;
};

function last_week_monday()//上个星期的星期一
{
	var myDate = new Date();
	myDate.setDate( myDate.getDate() -myDate.getDay()-6 ); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("上个星期的星期一"+firstDay);
	return firstDay;
};

function last_week_sunday()//上个星期的星期日
{
	var myDate = new Date();
	myDate.setDate( myDate.getDate() -myDate.getDay() ); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("上个星期的星期日"+firstDay);
	return firstDay;
};

function last_last_week_monday()//上上个星期的星期一
{
	var myDate = new Date();
	myDate.setDate( myDate.getDate() -myDate.getDay()-13 );  
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("上上个星期的星期一"+firstDay);
	return firstDay;
};

function last_last_week_sunday()//上上个星期的星期日
{
	var myDate = new Date();
	myDate.setDate( myDate.getDate() -myDate.getDay()-7 ); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("上上个星期的星期日"+firstDay);
	return firstDay;
};
	
function  now_date()//当前日期
{
	var myDate = new Date();
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day=myDate.getDate()
	var firstDay = month+"/"+day+"/"+year;
	//alert("当前日期"+firstDay);
	return firstDay;
};

function now_month_first_day()//当前月份的一号
{
	var myDate = new Date();
	//myDate.setDate( myDate.getDate()  ); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var firstDay = month+"/"+"01/"+year;
	//alert("当前月份的一号"+firstDay);
	return firstDay;
};

function now_month_end_day()//当前月份的最后一天
{
	var myDate = new Date();
	myDate.setMonth( myDate.getMonth() + 1 ); //增加一个月
	myDate.setDate( myDate.getDate() -myDate.getDate() );//减去多余的日期 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day =myDate.getDate();
	var firstDay = month+"/"+day+"/"+year;
	//alert("当前月份的最后一天"+firstDay);
	return firstDay;
};

function last_month_first_day()//上个月的一号
{
	var myDate = new Date();
	myDate.setMonth( myDate.getMonth()); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day =myDate.getDate();
	month=month-1
	if (month<=0) 
	{
		month=12+month
		year=year-1
	}
	var firstDay = month+"/01/"+year;
	//alert("上个月的一号"+firstDay);
	return firstDay;
};

function last_month_end_day()
{
	var myDate = new Date();//上个月最后一天
	myDate.setDate( myDate.getDate() -myDate.getDate() );//减去多余的日期 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day =myDate.getDate();
	var firstDay = month+"/"+day+"/"+year;
	//alert("上个月最后一天"+firstDay);
	return firstDay;
	
}
	
function last_last_month_first_day()
{
	var myDate = new Date();//上上个月的一号
	myDate.setMonth( myDate.getMonth()); 
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day =myDate.getDate();
	month=month-2
	if (month<=0) 
	{
		month=12+month
		year=year-1
	}
	var firstDay = month+"/01/"+year;
	//alert("上上个月的一号:"+firstDay);
	return firstDay;
};

function last_last_month_end_day()
{
	var myDate = new Date();//上上个月最后一天
	myDate.setDate( myDate.getDate() -myDate.getDate()-1 );//减去多余的日期
	myDate.setDate( myDate.getDate() -myDate.getDate() );//减去多余的日期
	var month = myDate.getMonth()+1;
	var year = myDate.getFullYear();
	var day =myDate.getDate();
	var firstDay = month+"/"+day+"/"+year;
	return firstDay;
	//alert("上上个月最后一天:"+firstDay);
}
	

你可能感兴趣的:(Date,function,脚本)