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://cdiso.cn/article/dscooog.html