JavaScript学习笔记之Date的常用方法

来源:互联网 发布:电子账单软件 编辑:程序博客网 时间:2024/04/30 01:39
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title></title></head><body>    <script type="text/javascript">        // 获取系统时间:        var date = new Date();        document.write("当前时间:" + date + "<br/>");                       document.write("星期:" + date.getDay() + "<br/>");                  document.write("年:" + date.getFullYear() + "<br/>");        document.write("月:" + date.getMonth() + "<br/>");   // 月份从0开始;        document.write("日:" + date.getDate() + "<br/>");        document.write("时:" + date.getHours() + "<br/>");        document.write("分:" + date.getMinutes() + "<br/>");        document.write("秒:" + date.getSeconds() + "<br/>");        document.write("毫秒:" + date.getMilliseconds() + "<br/>");        document.write("微秒:" + date.getTime() + "<br/>");        // 修改时间:        date.setFullYear(2020, 11, 21);        document.write("修改后的时间:" + date + "<br/>");    </script></body></html>

0 0
原创粉丝点击