web前端全系列 教程
1839个小节阅读:2243.2k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
Date
的实例对象,有几十个自己的方法,分为三类
to
类:从Date
对象返回一个字符串,表示指定的时间。get
类:获取Date
对象的日期和时间。set
类:设置Date
对象的日期和时间。
Date.prototype.toUTCString()
toUTCString
方法返回对应的 UTC 时间,也就是比北京时间晚8个小时
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toUTCString()
// "Fri, 31 Dec 2021 16:00:00 GMT"
Date.prototype.toDateString()
toDateString
方法返回日期字符串(不含小时、分和秒)
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toDateString() // "Sat Jan 01 2022"
Date.prototype.toTimeString()
toTimeString
方法返回时间字符串(不含年月日)
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toTimeString() // 00:00:00 GMT+0800 (中国标准时间)
Date.prototype.toLocaleDateString()
toLocaleDateString
方法返回一个字符串,代表日期的当地写法(不含小时、分和秒)
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toLocaleDateString() // 2022/1/1
Date.prototype.toLocaleTimeString()
toLocaleTimeString
方法返回一个字符串,代表时间的当地写法(不含年月日)
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toLocaleTimeString() // 上午12:00:00
实时效果反馈
1. 下列代码,运行结果是:
xxxxxxxxxx
var d = new Date(2022, 0, 1);
d.toLocaleTimeString()
A Sat Jan 01 2022
B 上午12:00:00
C 2022/1/1
D 00:00:00 GMT+0800 (中国标准时间)
答案
1=>B