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'
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义