0
点赞
收藏
分享

微信扫一扫

JS第十一天

嚯霍嚯 2022-04-24 阅读 113
javascript

JS的Date对象的方法2

toSTring() 把Date对象转换为字符串
console.log(oDate1.toString());

toDateString() 把Date对象的日期部分转换为字符串
console.log(oDate1.toDateString());

toTimeString() 把Date对象的时间部分转换为字符串
console.log(oDate1.toTimeString());

toLocalString() 根据本地时间格式,把Date对象转换为字符串
console.log(oDate1.toLocalString());

toLocalDateString() 根据本地时间格式,把Date对象的日期部分转换为字符串
console.log(oDate1.toLocalDateString());

toLocalTimeString() 根据本地时间格式,把Date对象的时间部分转换为字符串
console.log(oDate1.toLocalTimeString());

toUTCString() 根据世界时间,把Date对象转换为字符串

toISOString() 使用ISO标准返回字符串的日期格式
console.log(oDate1.toString());

toJSON() 以JSON数据返回日期字符串
console.log(oDate1.JSON());

valueOf() 返回Date对象的原始值
console.log(oDate1.valueOf());
console.log(new Date(23435));

UTC() 根据世界时间返回1970年1月1日到指定日期的毫秒数
console.log(Date.UTC(1970,1,2));

parse() 返回1970年1月1日午夜到指定日期(字符串)的毫秒数
console.log(Date.parse(“1970,1,2”));

定时器
(1)setInterval函数
setInterval(callback,ms) 循环定时器
callback:回调函数 当方法执行完之后调用
ms:毫秒
每隔多长时间执行一次回调函数
清除定时器 clearInterval(name)
(2)setTimeout函数
setTimeout(callback,ms) 延迟定时器
callback:回调函数 当方法执行完之后调用
ms:毫秒
延迟多长时间执行一次函数 只执行一次
清除:clearTimeout(name);

举报

相关推荐

web第十一天

HCIP 第十一天

倒数第十一天

打卡学习第十一天

JavaScript学习的第十一天

0 条评论