5.1内部对象

5.1Date

标准对象类型

typeof 123
'number'
typeof '123'
'string'
typeof true 
'boolean'
typeof NAN
'undefined'
typeof []
'object'
typeof {}
'object'
typeof dzj.age
'function'

 Date基本使用

获得各种时间

var now=new Date();
        now.getFullYear();//获取当前年份
        now.getMonth();//获得当前月份
        now.getDate();//获取当前日期
        now.getDay();//星期几
        now.getHours();//几时
        now.getMinutes();//几分
        now.getSeconds();//几秒
        now.getTime();//时间戳 世界唯一
        console.log(new Date(1659058132142));//将时间戳转换为时间Fri Jul 29 2022 09:28:52 GMT+0800 (中国标准时间)

 转化成各种时间

new Date(1659058132142)
Fri Jul 29 2022 09:28:52 GMT+0800 (中国标准时间)
now.toLocaleString()
'2022/7/29 09:33:18'
now.toGMTString()
'Fri, 29 Jul 2022 01:33:18 GMT'

 

posted @   吾辈皆喜黑丝  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示