Rahul Saini
Rahul Saini

Reputation: 937

To convert date format to the time stamp

How to calculate the start of the day.

I calculate by => moment().startOf('day').toISOString()

it returns

2019-09-12T00:00:00.000

But I want to in this format "2019-09-12 00:00:00.000"

How can we get,Please help me.

Upvotes: 0

Views: 50

Answers (2)

Darpan Rangari
Darpan Rangari

Reputation: 1570

Instead of using .toISOString() method you can simply use format().

As per momentjs doc here

.toISOString() returns a timestamp in UTC, even if the moment in question is in local mode.

Use it like this:

moment().startOf('day').format('YYYY-MM-DD hh:mm:ss:SSS')

Hope this helps happy coding!!!

Upvotes: 1

Oleg Levin
Oleg Levin

Reputation: 3621

var formatedDate= moment().startOf('day').format('YYYY-MM-DD HH:mm:ss,sss');

Upvotes: 1

Related Questions