Is there a way to remove hh: mm from moment .js, moment (). Add (2, 'days'). Calendar ()?

I only need to show the day of the week as a result, and I am looking for an inline format method at the .js moment before using reg ex for the job.

What I get:

moment().add(2, 'days').calendar() = "Thursday at 12:46 PM"

I only need to get Thursday

+4
source share
1 answer

Instead of using, calendaryou want to use format:

moment().add(2, 'days').format('dddd') // "Thursday"

The API docs explain what calendargives a date compared to a key date , while it formatallows you to format the date as you like .

+6
source

Source: https://habr.com/ru/post/1656678/


All Articles