NaMo
NaMo

Reputation: 533

Today's date: Moment construction falls back to js Date

I want today's date like: 2017/06/23

I am doing this:

moment().format('YYYY/MM/DD'))

It gives me error:

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release.

Tried many solutions from SO and also Github issue, still nothing is working out. Please help me out of this.

Upvotes: 1

Views: 795

Answers (1)

Shubham Khatri
Shubham Khatri

Reputation: 281726

Pass a new Date() without parameters to moment object.

console.log(moment(new Date()).format('YYYY/MM/DD'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>

Upvotes: 1

Related Questions