I am trying to change moment for date-fns
moment: moment().startOf('day').subtract(1, 'day').toDate(),
date-fns: subDays(new Date(), 1),
Moment give me back this: Moment: Thu Jun 10 2021 00:00:00 GMT+0200 (hora de verano de Europa central)
and date-fns this: Datefn: Thu Jun 10 2021 12:17:35 GMT+0200 (hora de verano de Europa central)
I am wondering if is it any way to get the same time on date-fns. This 00:00:00 instead of this 12:17:35
I am trying to change moment for date-fns
moment: moment().startOf('day').subtract(1, 'day').toDate(),
date-fns: subDays(new Date(), 1),
Moment give me back this: Moment: Thu Jun 10 2021 00:00:00 GMT+0200 (hora de verano de Europa central)
and date-fns this: Datefn: Thu Jun 10 2021 12:17:35 GMT+0200 (hora de verano de Europa central)
I am wondering if is it any way to get the same time on date-fns. This 00:00:00 instead of this 12:17:35
Share Improve this question asked Jun 11, 2021 at 10:36 SargentogatoSargentogato 1652 gold badges2 silver badges10 bronze badges 2-
2
Have you tried using
startOfToday()
instead ofnew Date()
? – Jon Skeet Commented Jun 11, 2021 at 10:41 - No, I haven't but I will, thanks – Sargentogato Commented Jun 11, 2021 at 11:56
1 Answer
Reset to default 5Try this it should work.
date-fns: startOfDay(subDays(new Date(), 1))