js当天月份时间戳的获取

2021-12-06  本文已影响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; // 前天时间戳
上一篇 下一篇

猜你喜欢

热点阅读