js 取得当天0点 / 23:59:59 时间

js 取得今天0点:

const start = new Date(new Date(new Date().toLocaleDateString()).getTime());
console.log(start); //Mon Dec 04 2017 00:00:00 GMT+0800 (中国标准时间)

同理算出:

js 取得今天 23:59:59

const start = new Date(new Date(new Date().toLocaleDateString()).getTime()+24*60*60*1000-1);
console.log(start); //Mon Dec 04 2017 23:59:59 GMT+0800 (中国标准时间)

其他也是同理类推

 

posted @ 2017-12-04 15:36  James2019  阅读(35761)  评论(0编辑  收藏  举报