javascriptmomentjs

Get the beginning of the day in timestamp using Momentjs library


For instance the timestamp is: 1542769200 which its output is: GMT: Wednesday, 21 November 2018 03:00:00. However what I am trying to achieve is to get the beginning of this day, by having the hour, minutes and seconds set to 00.00.00.


Solution

  • moment(moment(moment().unix() * 1000).startOf('day').unix() * 1000)