摘要:获取某年某月某日是周几,以及该月1号周几,以及该月多少天。 [javascript] var    Nowdate = ("2012-11-22").split("-"),    //获取某一日期           NowYear = parseInt(Nowdate[0]),    //某年份           NowMonth = parseInt(Nowdate[1]),    //某月份           Nowday = parseInt(Nowdate[2]),    //某天           date = new Date(),          weekday=new Array(7);  weekday[0]="星期日";  weekday[1]="星期一";  weekday[2]="星期二";  weekday[3]="星期三";  weekday[4]="星期四";  weekday[5]="星期五";  weekday[6]="星期六";  date.setFullYear(NowYear);//把当前年份设为某年   date.setMonth(NowMonth-1);//把当前月份设为某月   date.setDate(Nowday);//把当前日设为某天   document.write(NowYear+"年"+NowMonth+"月"+Nowday+"号是"+weekday[date.getDay()]+"<br />");    date.setDate(1);    //把当前日期设为该月1号   document.write(NowYear+"年"+NowMonth+"月1号是"+weekday[date.getDay()]+"<br />");    date.setMonth(date.getMonth()+1);                                //月份+1(即下月1号)           var LastDay = new Date(date-3600000*24);                //日份-1(即本月最后一天)   document.write(NowYear+"年"+NowMonth+"月一共"+LastDay.getDate()+"天<br />"); 

小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

获取某年某月某日是周几,以及该月1号周几,以及该月多少天。
[javascript]
var    Nowdate = ("2012-11-22").split("-"),    //获取某一日期  
        NowYear = parseInt(Nowdate[0]),    //某年份  
        NowMonth = parseInt(Nowdate[1]),    //某月份  
        Nowday = parseInt(Nowdate[2]),    //某天  
        date = new Date(), 
        weekday=new Array(7); 
weekday[0]="星期日"; 
weekday[1]="星期一"; 
weekday[2]="星期二"; 
weekday[3]="星期三"; 
weekday[4]="星期四"; 
weekday[5]="星期五"; 
weekday[6]="星期六"; 
date.setFullYear(NowYear);//把当前年份设为某年  
date.setMonth(NowMonth-1);//把当前月份设为某月  
date.setDate(Nowday);//把当前日设为某天  
document.write(NowYear+"年"+NowMonth+"月"+Nowday+"号是"+weekday[date.getDay()]+"<br />"); 
 
date.setDate(1);    //把当前日期设为该月1号  
document.write(NowYear+"年"+NowMonth+"月1号是"+weekday[date.getDay()]+"<br />"); 
 
date.setMonth(date.getMonth()+1);                                //月份+1(即下月1号)          
var LastDay = new Date(date-3600000*24);                //日份-1(即本月最后一天)  
document.write(NowYear+"年"+NowMonth+"月一共"+LastDay.getDate()+"天<br />"); 

var    Nowdate = ("2012-11-22").split("-"),    //获取某一日期
        NowYear = parseInt(Nowdate[0]),    //某年份
        NowMonth = parseInt(Nowdate[1]),    //某月份
        Nowday = parseInt(Nowdate[2]),    //某天
        date = new Date(),
        weekday=new Array(7);
weekday[0]="星期日";
weekday[1]="星期一";
weekday[2]="星期二";
weekday[3]="星期三";
weekday[4]="星期四";
weekday[5]="星期五";
weekday[6]="星期六";
date.setFullYear(NowYear);//把当前年份设为某年
date.setMonth(NowMonth-1);//把当前月份设为某月
date.setDate(Nowday);//把当前日设为某天
document.write(NowYear+"年"+NowMonth+"月"+Nowday+"号是"+weekday[date.getDay()]+"<br />");

date.setDate(1);    //把当前日期设为该月1号
document.write(NowYear+"年"+NowMonth+"月1号是"+weekday[date.getDay()]+"<br />");

date.setMonth(date.getMonth()+1);                                //月份+1(即下月1号)       
var LastDay = new Date(date-3600000*24);                //日份-1(即本月最后一天)
document.write(NowYear+"年"+NowMonth+"月一共"+LastDay.getDate()+"天<br />");

 

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

本文固定链接: http://www.js-code.com/js/js_8822.html