JS第十一天

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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值