zoukankan      html  css  js  c++  java
  • Cocos Creator JS 获取当前日期与时间

    var testDate = new Date();

    testDate.getYear();//获取当前年份(2位)

    testDate.getFullYear(); //获取完整的年份(4位,1970-????)

    testDate.getMonth(); //获取当前月份(0-11,0代表1月)

    testDate.getDate(); //获取当前日(1-31)

    testDate.getDay(); //获取当前星期X(0-6,0代表星期天)

    testDate.getTime(); //获取当前时间(从1970.1.1开始的毫秒数)

    testDate.getHours(); //获取当前小时数(0-23)

    testDate.getMinutes(); //获取当前分钟数(0-59)

    testDate.getSeconds(); //获取当前秒数(0-59)

    testDate.getMilliseconds(); //获取当前毫秒数(0-999)

    testDate.toLocaleDateString(); //获取当前日期

    var mytime=testDate.toLocaleTimeString();//获取当前时间

    testDate.toLocaleString( ); //获取日期与时间

  • 相关阅读:
    数组
    js--函数
    for循环
    运算符
    js 正则表达式
    js DOM节点
    js 字符串
    js 函数
    2018-12-26 课堂笔记 for循环
    2018-12-25 课堂笔记 js
  • 原文地址:https://www.cnblogs.com/luorende/p/9237614.html
Copyright © 2011-2022 走看看