zoukankan      html  css  js  c++  java
  • [妙味JS基础]第十课:日期对象、时钟倒计时

    知识点总结

    •  时间、年、月、日、时、分、秒
        new Date()  ->当前系统的时间对象
      数字类型:    getFullYear()、getYear()、getUTCFullYear()    getYear(),2000年之后返回1XX,例如:2014年返回114(不推荐使用)    getFullYear(),返回4位数,例如:2014年返回2014    getUTCFullYear(),返回UTC的年份,也是四位数    getMonth() //月+1;
       getDate() //日    getDay() //星期,0为星期日,1为星期1,需要判断一下    getHours() //时    getMinutes()//分   getSeconds()//秒

      还需要对时分秒,不足10的需要前面补0,即:
      function toTwo (n){
        return n<10 ? '0'+n : ''+ n
      }
    • 倒计时
        new Date()
            数字形式:new Date(2014,0,21,22,17,01);  注:数字形式月份,如果希望是5月,需要在Date()中设置成4
            字符串: new Date('January 21,2014 22:17:01')
            月份:January、February、March、April、May、June
                 July、August、September、October、November、December
    
        时间转换公式
            t = Math.floor((未来的时间-当前的时间)/1000)  秒(1秒=1000毫秒)
         1天=1*24*60*60秒=86400 天:Math.floor(t/86400) 时:Math.floor(t%86400/3600) 分:Math.floor(t%86400%3600/60) 秒:t%60 时间戳:getTime() 返回从1970年1月1日0点0分0秒0毫秒
  • 相关阅读:
    C# 中==和Equal的区别
    3dmath复习随笔
    3dmax学习资料记录
    [官方教程] Unity 5 BLACKSMITH深度分享
    [技术] [插件精选] 炫酷粒子特效(下)
    Unity3D总结:关于射线碰撞
    Unity3D将来时:IL2CPP(上)
    3DMAX 9 角色建模3 uv展开
    php,c# hamsha1
    U3D 的一些基础优化
  • 原文地址:https://www.cnblogs.com/joya0411/p/3580953.html
Copyright © 2011-2022 走看看