js关于日期的操作

var now = new Date() //当前日期

var year = now.getFullYear() //当前年份

var month = now.getMonth() + 1 //当前月份

var date = now.getDate() //当前日

var day = now.getDay() //当前星期几(0为星期日)

var hour = now.getHours() // 当前时间(时)

var minute = now.getMinutes() // 当前时间(分)

var second = now.gerSeconds() // 当前时间(秒)

var time = now.getTime() // 当前时间戳

var allDate = new Date(year, month, 0).getDate() //当月一共有多少天

var allWeek = Math.ceil((allDates + (firstDay - 1)) / 7) //当月一共有多少周

var firstDay = new Date(year, month - 1, 1).getDay() // 当月第一天是星期几

var weekBeginDate = formatDate(new Date(year, month - 1, date - day + 1)) //本周周一日期

var weekEndDate  = formatDate(new Date(year, month - 1, date+ ( 7 - day))) //本周周日日期

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值