MomentJS - Day of year


Advertisements

This method will take care of getting and setting the day of year. The range given is 0-366. If the input to set is greater than the range, it will show up the next year.

Syntax

moment().dayOfYear(Number);
moment().dayOfYear();

Example

var m = moment().dayOfYear();
var d = moment().dayOfYear(320);
var a = moment().dayOfYear(400);

Output

Day of Year
momentjs_getter_setter.htm
Advertisements