Round a timestamp to the nearest date

前端 未结 7 1715
Happy的楠姐
Happy的楠姐 2020-12-03 11:23

I need to group a bunch of items in my web app by date created.

Each item has an exact timestamp, e.g. 1417628530199. I\'m using Moment.js and its \"tim

7条回答
  •  攒了一身酷
    2020-12-03 12:00

    Here is a clean way to get just the date in one line with no dependencies:

    let d = new Date().setHours(0, 0, 0, 0);
    

提交回复
热议问题