Getter/Setter

MomentJS has many methods to get/set the date inputs. Get will allow us to read the required input unit and set will allow to modify the input unit. This chapter discusses in detail the get/set methods to be used on the moment.

The following table shows the get/set methods available −

MethodSyntax
Millisecondmoment().millisecond(Number)moment().millisecond();moment().milliseconds(Number);moment().milliseconds();
Secondmoment().second(Number);moment().second();moment().seconds(Number);moment().seconds();
Minutemoment().minute(Number);moment().minute();moment().minutes(Number);moment().minutes();
Hourmoment().date(Number);moment().date();moment().dates(Number);moment().dates();
Day of weekmoment().day(Number|String);moment().day();moment().days(Number|String);moment().days();
Date of Monthmoment().date(Number);moment().date();moment().dates(Number);moment().dates();
Day of yearmoment().dayOfYear(Number);moment().dayOfYear();
Week of yearmoment().week(Number);moment().week();moment().weeks(Number);moment().weeks();
Week of year (ISO)moment().isoWeek(Number);moment().isoWeek();moment().isoWeeks(Number);moment().isoWeeks();
Monthmoment().month(Number|String);moment().month();
Quartermoment().quarter();moment().quarter(Number);moment().quarters();moment().quarters(Number);
Yearmoment().year(Number);moment().year();
Week yearmoment().weekYear(Number);moment().weekYear();
Weeks in yearmoment().weeksInYear();
Getmoment().get(‘year’);moment().get(‘month’);moment().get(‘date’);moment().get(‘hour’);moment().get(‘minute’);moment().get(‘second’);moment().get(‘millisecond’);
Setmoment().set(String, Int);moment().set(Object(String, Int));
Maximummoment.max(Moment[,Moment…]);moment.max(Moment[]);
Minimummoment.min(Moment[,Moment…]);moment.min(Moment[]);

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *