MomentJS有很多方法可以获取/设置日期输入. Get将允许我们读取所需的输入单元,并设置将允许修改输入单元.本章详细讨论了当前使用的get/set方法.
下表显示了可用的get/set方法 :
Method | Syntax |
---|---|
Millisecond | moment().millisecond(Number) moment().millisecond(); moment().milliseconds(Number); moment().milliseconds(); |
Second | moment().second(Number); moment().second(); moment().seconds(Number); moment().seconds(); |
Minute | moment().minute(Number); moment().minute(); moment().minutes(Number); moment().minutes(); |
Hour | moment().date(Number); moment().date(); moment().dates(Number); moment().dates(); |
Day of week | moment().day(Number|String); moment().day(); moment().days(Number|String); moment().days(); |
Date of Month | moment().date(Number); moment().date(); moment().dates(Number); moment().dates(); |
Day of year | moment().dayOfYear(Number); moment().dayOfYear(); |
Week of year | moment().week(Number); moment().week(); moment().weeks(Number); moment().weeks(); |
Week of year (ISO) | moment().isoWeek(Number); moment().isoWeek(); moment().isoWeeks(Number); moment().isoWeeks(); |
Month | moment().month(Number|String); moment().month(); |
Quarter | moment().quarter(); moment().quarter(Number); moment().quarters(); moment().quarters(Number); |
Year | moment().year(Number); moment().year(); |
Week year | moment().weekYear(Number); moment().weekYear(); |
Weeks in year | moment().weeksInYear(); |
Get | moment().get('year'); moment().get('month'); moment().get('date'); moment().get('hour'); moment().get('minute'); moment().get('second'); moment().get('millisecond'); |
Set | moment().set(String, Int); moment().set(Object(String, Int)); |
Maximum | moment.max(Moment[,Moment...]); moment.max(Moment[]); |
Minimum | moment.min(Moment[,Moment...]); moment.min(Moment[]); |