Setting time part to 0 in ISO date format in moment.js

Viewed 3591

I am getting date in ISO format using moment.js using:

let matchDate= moment().add(1, 'day').toISOString();

It gives me matchDate in the form:

2017-08-01T18:30:00.000Z

I want to set each numeric value after T as 0 and get the result as

2017-08-01T00:00:00.000Z

How can I do this?

2 Answers

You can simply use the startOf(unitOfTime) function from moment.

Here how's your code will look like:

let matchDate = moment().add(1, 'day').startOf('day').toISOString();

Reference answer: https://stackoverflow.com/a/28592432/4539906

Related