2021-05-09时间对象

时间对象

< !DOCTYPE html>
< html>
< head>
< title>时间对象< /title>
< meta charset=“utf-8”>
< /head>
< body>

< /body>
< script type=“text/javascript”>
//时间对象
//获取当前的时间对象
var now = new Date();
//获取某个时间点的时间对象
var last = new Date(2020,9,1);//代表是10月1日
console.log(last)
//除星期外 所有get方法都有set方法
//例子:3天后过期
var s= now.setDate(now.getDate() + 3);
now.setDate(8);
//获取当前的年
console.log(now.getFullYear());
//获取当前的月(0-11)
console.log(now.getMonth());
//获取当前的日期
console.log(now.getDate());
//获取当前的星期
console.log(now.getDay());
//获取当前小时
console.log(now.getHours());
//获取当前分钟
console.log(now.getMinutes());
//获取当前的秒
console.log(now.getSeconds());
//获取当前的时间戳—距离1970年的毫秒数
console.log(now.getTime());

< /script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值