获取时间

//获取当天零点的时间
const beg = new Date(new Date().setHours(0, 0, 0, 0));
//获取当天23:59:59的时间
const end = new Date(new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 - 1);

获取时间戳

//获取当天零点的时间戳 
const beg = new Date(new Date().setHours(0, 0, 0, 0)).getTime(); 
//获取当天23:59:59的时间戳 
const end = new Date(new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 - 1).getTime(); 
Last modification:March 1st, 2021 at 04:51 pm
如果觉得我的文章对你有用,请随意赞赏