0

Why moment().startOf('day') shows as Moment<2020-05-01T00:00:00+02:00>, in Nodejs ??

I want to show the date only, how to get the date only without Moment word and < > symbols.. !

itneg
  • 73
  • 1
  • 10

1 Answers1

2

So startOf() returns a moment object, what you're wanting to do is some kind of format of the output object.

console.log(moment()
  .endOf('day')
  .toISOString()) // 2020-05-18T21:59:59.999Z

Skaleb
  • 308
  • 2
  • 10
  • From the question, it seems like OP wants the string. But you're right, shouldn't assume – Skaleb May 18 '20 at 13:45
  • Read the comments. :) – sandrooco May 18 '20 at 13:46
  • In fact I needed endOf and startOf day in milliseconds or epoch format, made this solution `+moment().startOf('day') ` But yes this solves the question I made, removes the `Moment< >` and gives the date only.. – itneg May 18 '20 at 14:03