美文网首页
js当天月份时间戳的获取

js当天月份时间戳的获取

作者: 前端金城武 | 来源:发表于2021-12-06 17:38 被阅读0次
let now = new Date();
let Now = now.getTime(); //当前时间戳
let nowYear = now.getFullYear(); //当前年
let nowMonth = now.getMonth();//当前月
let nowDay = now.toLocaleDateString();//当前天
let firstDay = new Date(nowYear, nowMonth, 1).getTime()//本月开始时间戳
let LastDay = new Date(nowYear, nowMonth + 1, 0).getTime(); // 本月结束时间戳
let Day = new Date(nowDay).getTime(); // 当天0点时间戳
let yesterday = new Date(nowDay).getTime() - 86400000; // 昨天时间戳, 86400000为24h的时间戳
let beforeYesterday = new Date(nowDay).getTime() - 86400000 * 2; // 前天时间戳

相关文章

网友评论

      本文标题:js当天月份时间戳的获取

      本文链接:https://www.haomeiwen.com/subject/nxhnxrtx.html