Date对象及函数

来源:互联网 发布:淘宝美工薪资待遇 编辑:程序博客网 时间:2024/05/31 18:37

1.Date对象

语法:

   var 日期对象=new Date(参数)
     参数格式:MM DD,YYYY,hh:mm:ss

2.Date对象的方法
方法 说明
getDate() 返回 Date 对象的一个月中的每一天,其值介于1~31之间
getDay()
返回 Date 对象的星期中的每一天,其值介于06之间
getHours()
返回 Date 对象的小时数,其值介于023之间
getMinutes()
返回 Date 对象的分钟数,其值介于059之间
getSeconds()
返回 Date 对象的秒数,其值介于059之间
getMonth()返回 Date 对象的月份,其值介于011之间
getFullYear()返回 Date对象的年份,其值为4位数
getTime()返回自某一时刻(197011日)以来的毫秒数

3.定时函数
语法:setTimeout()
 setTimeout("调用的函数",等待的毫秒数)
  setInterval()
语法:setInterval("调用的函数",间隔的毫秒数)

4.清除函数
clearTimeout()
 clearTimeout(setTimeOut()返回的ID值)
clearInterval ()
clearInterval(setInterval()返回的ID值)

5.总结:
window对象实现弹出窗口、关闭当前窗口、弹出页面消息框等效果
Date对象获得当前系统的日期、时间
定时函数:setTimeout()和setInterval()
history和location对象实现浏览器中“后退”、“前进”和“刷新”
document对象的方法
 getElementById()
 getElementsByName()
 getElementsByTagName()




原创粉丝点击