求JS代码详细解释,每个属性····高分····
today=newDate();varday;vardate;varcentry;if(today.getDay()==0)day="星期日"if(today.getDa...
today = new Date();
var day; var date;
var centry ;
if(today.getDay()==0) day = "星期日"
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
centry="";
if (today.getFullYear()<2000 ) centry = "19" ;
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ;
date2 = "" + day ;
document.write( date1+date2); 展开
var day; var date;
var centry ;
if(today.getDay()==0) day = "星期日"
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
centry="";
if (today.getFullYear()<2000 ) centry = "19" ;
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ;
date2 = "" + day ;
document.write( date1+date2); 展开
2个回答
展开全部
应该是个日期控件的一部分
today = new Date(); //获取当前日期,Date()为内置函数
var day; var date; //定义变量
var centry ;
if(today.getDay()==0) day = "星期日" //用getDay()方法获取日期当天星期几,若为"0"则是"星期日"
if(today.getDay()==1) day = "星期一" //同上
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六" //同上
centry="";
if (today.getFullYear()<2000 ) centry = "19" ; //用getFullYear方法判断是否小于2000,如果小于,则赋值为19;
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ; //给date1赋值,显示应为"2011年10月28日"
date2 = "" + day ; //给date2赋值,前面加了个空格,显示为" 星期五"
document.write( date1+date2); //输出结果-----2011年10月28日 星期五
today = new Date(); //获取当前日期,Date()为内置函数
var day; var date; //定义变量
var centry ;
if(today.getDay()==0) day = "星期日" //用getDay()方法获取日期当天星期几,若为"0"则是"星期日"
if(today.getDay()==1) day = "星期一" //同上
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六" //同上
centry="";
if (today.getFullYear()<2000 ) centry = "19" ; //用getFullYear方法判断是否小于2000,如果小于,则赋值为19;
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ; //给date1赋值,显示应为"2011年10月28日"
date2 = "" + day ; //给date2赋值,前面加了个空格,显示为" 星期五"
document.write( date1+date2); //输出结果-----2011年10月28日 星期五
展开全部
代码功能是输出当前日期和当天星期几
today = new Date(); //取得当前日期
var day; var date;
var centry ; //定义三个变量
if(today.getDay()==0) day = "星期日" // 判断是星期几
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
centry="";
if (today.getFullYear()<2000 ) centry = "19" ; //如果日期小于公元2000年,则为19世纪
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ; //组合日期字符串
date2 = "" + day ; // 组合星期几
document.write( date1+date2); //输出结果
today = new Date(); //取得当前日期
var day; var date;
var centry ; //定义三个变量
if(today.getDay()==0) day = "星期日" // 判断是星期几
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
centry="";
if (today.getFullYear()<2000 ) centry = "19" ; //如果日期小于公元2000年,则为19世纪
date1 = centry + (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ; //组合日期字符串
date2 = "" + day ; // 组合星期几
document.write( date1+date2); //输出结果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询