查看: 2118|回复: 0
收起左侧

[电脑数码] [原创]js简单时间特效详细讲解

[复制链接]
发表于 2006-11-30 17:05:00 | 显示全部楼层 |阅读模式 <
[watermark][html]
<p id="cs">这里将显示时间</p><!--设置p标签,(不明白的查看html相关资料)并设置其id为cs,-->
<script>
function thetime(){                             //定义一个名为thetime的函数
var theday = new Date()                         //定义一个日期对象(获取系统当前日期:例:Thu Nov 30 16:33:05 UTC+0800 2006)
var theyear = theday.getYear()                  //获取日期里的年份,如上的2006
var themonth = theday.getMonth()+1              //获取月份
var thedays = theday.getDate()                  //获取当前日
var thehours = theday.getHours()                //获取小时
var theminutes = theday.getMinutes()            //获取分
var theseconds = theday.getSeconds()            //获取秒
var tt = ("现在是:"+theyear+"年"+themonth+"月"+thedays+"日"+thehours+"时"+theminutes+"分"+theseconds+"秒")//显示时间字符串
document.getElementById("cs").innerHTML=tt     //在id为cs的标签中输入显示时间的字符串
setTimeout("thetime()",1000)                   //设置多长时间执行一次thetime函数,单位为毫秒,即1000=1秒
}
thetime();                                      
</script>
[/html][/watermark]
您需要登录后才可以回帖 登录 | 注册 微信登录 手机动态码快速登录

本版积分规则

QQ|Archiver|手机版|小黑屋|删帖指引|阳新新阳网 ( 鄂ICP备19013424号-2|42022202000111 )

GMT+8, 2024-7-8 15:34 , Processed in 0.486019 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.