A moment
object is a lightweight wrapper on a JavaScript Date
, with a few extra properties. Neither can do what you are asking, because they both represent time as the number of milliseconds elapsed since Jan 1st 1970 UTC at midnight.
Your best bet is just to store the year as a number, instead of a moment
or a Date
.
Consider:
var s = 'UN-UNK-2010';
var year = +s.split('-')[2];