我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

javascript周几,js 今天星期几

JS计算系统当前日期是星期几的几种方法

方法一:

站在用户的角度思考问题,与客户深入沟通,找到会泽网站设计与会泽网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计、网站制作、企业官网、英文网站、手机端网站、网站推广、域名申请、网页空间、企业邮箱。业务覆盖会泽地区。

// 计算系统当前是星期几var str = "今天是星期" + "日一二三四五六".charat(new Date().getDay());

方法二:

var a = new array("日", "一", "二", "三", "四", "五", "六");var week = new Date().getDay();var str = "今天是星期"+ a[week];

alert(str);

方法三:

var str = "今天是星期";var week = new Date().getDay();switch (week) { case 0 :

str += "日"; break; case 1 :

str += "一"; break; case 2 :

str += "二"; break; case 3 :

str += "三"; break; case 4 :

str += "四"; break; case 5 :

str += "五"; break; case 6 :

str += "六"; break;

}

alert(str);

方法四:

var str = "";var week = new Date().getDay();if (week == 0) {

str = "今天是星期日";

} else if (week == 1) {

str = "今天是星期一";

} else if (week == 2) {

str = "今天是星期二";

} else if (week == 3) {

str = "今天是星期三";

} else if (week == 4) {

str = "今天是星期四";

} else if (week == 5) {

str = "今天是星期五";

} else if (week == 6) {

str = "今天是星期六";

}

alert(str);

怎么用javascript确定今天是周几

function clockon(clock){

var bgclock = document.getElementById(clock);

var now = new Date();

var year = now.getYear();

var month = now.getMonth();

var date = now.getDate();

var day =now.getDay();

var hour = now.getHours();

var minu = now.getMinutes();

var sec = now.getSeconds();

var week;

month = month+1;

if(month10)month="0"+month;

if(date10)date="0"+date;

if(hour10)hour="0"+hour;

if(minu10)minu="0"+minu;

if(sec10)sec ="0"+sec;

var arr_week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

week = arr_week[day];

var time=""

time=year+"年"+month+"月"+date+"日"+week+""+hour+":"+minu+":"+sec;

if(document.all){

bgclock.innerHTML="【"+time+"】"

}

var timer = setTimeout("clockon('bgclock')",200);

}

JS如何利用日期判断星期几?

一般一星期顺序如下:

星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"

function getMyDay(date){

var week;

if(date.getDay()==0) week="周日"

if(date.getDay()==1) week="周一"

if(date.getDay()==2) week="周二"

if(date.getDay()==3) week="周三"

if(date.getDay()==4) week="周四"

if(date.getDay()==5) week="周五"

if(date.getDay()==6) week="周六"

return week;

}

var w1 = getMyDay(new Date("2015-7-12"));


文章名称:javascript周几,js 今天星期几
网页地址:http://shouzuofang.com/article/dscooog.html

其他资讯