第一次翻译别人的东西,翻译的不好的地方,还请见谅,同时还请多多的提意见,不胜感激
原文地址: HTML
发贴人地址:
mydate = new Date();
seconds = mydate.getSeconds();
minutes = mydate.getMinutes();
hours = mydate.getHours();
day = mydate.getDay();
date = mydate.getDate();
month = mydate.getMonth();
year = mydate.getFullYear();
seconds = mydate.getSeconds();
minutes = mydate.getMinutes();
hours = mydate.getHours();
day = mydate.getDay();
date = mydate.getDate();
month = mydate.getMonth();
year = mydate.getFullYear();
第五步:
我们可以建立一些变量来对得到的时间变量做出相应的反应.比如,时间是星期天,你得到的变量是0。
再比如星期一得到的是1。所以当你对得到的变量做出反应时就会好一点。这里我们当为0时我们设置一个变量
等于星期天,当为1时变量等于星期一......
a.把变量转换成名字
- - - - - - - - - - - - - - - - - - - - - - - - - - if (day==0){
day = "Sunday"
} else if (day==1){
day = "Monday"
} else if (day==2){
day = "Tuesday"
} else if (day==3){
day = "Wednesday"
} else if (day==4){
day = "Thursday"
} else if (day==5){
day = "Friday"
} else if (day==6){
day = "Saturday"
}
- - - - - - - - - - - - - - - - - - - - - - - - - - if (month==0){
month = "January"
} else if (month==1){
month = "February"
} else if (month==2){
month = "March"
} else if (month==3){
month = "April"
} else if (month==4){
month = "May"
} else if (month==5){
month = "June"
} else if (month==6){
month = "July"
} else if (month==7){
month = "August"
} else if (month==8){
month = "September"
} else if (month==9){
month = "October"
} else if (month==10){
month = "November"
} else if (month==11){
month = "December"
}- - - - - - - - - - - - - - - - - - - - - - - - - - b.- - - - - - - - - - - - - - - - - - - - - - - - - -时间变化month = month + 1; - - - - - - - - - - - - - - - - - - - - - - - - - - c.- - - - - - - - - - - - - - - - - - - - - - - - - -让秒和分正确显示if (minutes<10) {
minutes = "0"+minutes;
}
if (seconds<10) {
seconds = "0"+seconds;
}这个就不要解释了吧- - - - - - - - - - - - - - - - - - - - - - - - - -第六步:把时间的24进制转换为12进制if (hours>12) {
hours = hours-12;
ampm = "PM";
} else {
ampm = "AM";
}
if (hours == 0) {
hours = 12;
}第七步:显示时间time = ((hours) + ":" + (minutes) + ":" + (seconds) + " " + (ampm));显示日期datefinal = ((day) + " " + (date) + " " + (month) + " " + (year)); - - - - - - - - - - - - - - 或者 - - - - - - - - - - - - - - - - -显示时间time = ((hours) + ":" + (minutes) + ":" + (seconds));显示日期datefinal = ((date) + "/" + (month) + "/" + (year));OK,其他的一些我觉得繁琐很简单的东西就没有弄过来了,主要的7步都拿过来了。其他的一些注释也省略了。如果需要或者有疑问请.好久没有发东西 这个很简单 虽然看起来很多代码核心是一个更新的问题我知道的有两种办法1.在第二桢加入ASgotoAndPlay(1);2.将所实现的功能改为在函数中实现setInterval(函数名,更新时间频率);
上一篇:学动画两年来学到的一点小经验
下一篇:for循环使用详解(c语言版)
