MomentJS - Year


Advertisements

This method will get/set the year. The range for year is -270,000 to 270,000.

Syntax

moment().year(Number);
moment().year();

Example

var m = moment().year();
var d = moment().year(2020);

Output

Year
momentjs_getter_setter.htm
Advertisements