zoukankan      html  css  js  c++  java
  • date对象

    一.代码示例 

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>时间</title>
    </head>
    <body>
        <script type="text/javascript">
        //获取当前时间
        var date = new Date();
        document.write(date);
        //转换为字符串
        document.write("<hr/>");
        document.write(date.toLocaleString());
        //得到当前的年份
        document.write("<hr/>");
        document.write("year :"+date.getFullYear());
        //获取当前的月份
        //返回的是0~11月,想要得到准确的值必须加一
        document.write("<hr/>");
        var date1 = date.getMonth()+1;
        document.write("month :"+date1);
        //获取当前星期
        //外国将星期日作为一周的开始,返回的是0~6
        document.write("<hr/>");
        document.write("week:"+date.getDay());
        //获取当前的天
        document.write("<hr/>");
        document.write("day:"+date.getDate());
        //获取当前小时
        document.write("<hr/>");
        document.write("hours:"+date.getHours());
        //获取当前分钟
        document.write("<hr/>");
        document.write("Minutes:"+date.getMinutes());
        //获取当前秒
        document.write("<hr/>");
        document.write("Seconds:"+date.getSeconds());
        //获取从1970 1 1到至今的毫秒数
        document.write("<hr/>");
        document.write("Time:"+date.getTime());
        </script>
    </body>
    </html>

  • 相关阅读:
    Linux--shell三剑客<sed>--07
    Linux--shell交互输入与循环语句--06
    Linux--shel分支语句--05
    Linux--shell grep与正则表达式--04
    Linux--shell编程原理--03
    Linux--shell重定向与文件处理命令--02
    Linux--shell的基本特性--01
    Docker数据卷
    Docker容器
    Docker的安装
  • 原文地址:https://www.cnblogs.com/zjm1999/p/10361306.html
Copyright © 2011-2022 走看看