How to find the day, month and year with moment.js
I know this has already been answered, but I stumbled across this question and went down the path of using format
, which works, but it returns them as strings when I wanted integers.
I just realized that moment comes with date
, month
and year
methods that return the actual integers for each method.
moment().date()
moment().month() // jan=0, dec=11
moment().year()
Just try with:
var check = moment(n.entry.date_entered, 'YYYY/MM/DD');
var month = check.format('M');
var day = check.format('D');
var year = check.format('YYYY');
JSFiddle