梦之都
JavaScript教程
setDate
函数设置date对象中月份的一天,并返回date对象距1970年1月1日午夜之间的毫秒数(时间戳)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>JavaScript setDate() 函数示例</title> </head> <body> <script type="text/javascript"> var d = new Date(); document.write(d); document.write("<br />"); document.write(d.setDate(5)); document.write("<br />"); document.write(d); document.write("<br />"); d = new Date(); d.setDate(-1) document.write(d); document.write("<br />"); d = new Date(); d.setDate(-33) document.write(d); document.write("<br />"); d = new Date(); d.setDate(33) document.write(d); </script> </body> </html>