javascriptreactjsdayjs

How can I round seconds to 0 with dayJS


I am creating an app which asks the users for 2 dates, then it calculates the time between them dates.

But the dates have seconds in them so instead of 90 minutes I am getting 89 minutes.

So I can convert this:

startTime: Sat Apr 09 2022 09:00:39 GMT+0100 (Irish Standard Time)

Into this:

startTime: Sat Apr 09 2022 09:00:00 GMT+0100 (Irish Standard Time)

I would preferably do this with DayJS


Solution

  • I came up with a solution with the help of James!

    values.startTime = dayjs(time[0].setUTCSeconds(0)).toDate();
    

    Thank you!