方法 | 语法 |
format |
moment().format();
moment().format(String);
|
Time from now |
moment().fromNow();
moment().fromNow(Boolean);
|
Time from X |
moment().from(Moment|String|Number|Date|Array);
|
Time to now |
moment().toNow();
moment().toNow(Boolean);
|
Time to X |
moment().to(Moment|String|Number|Date|Array);
moment().to(Moment|String|Number|Date|Array, Boolean);
|
Calendar Time |
moment().calendar();
moment().calendar(referenceTime);
moment().calendar(referenceTime, format);
p> |
Difference |
moment().diff(Moment|String|Number|Date|Array);
moment().diff(Moment|String|Number|Date|Array, String);
moment().diff(Moment|String| Number|Date|Array, String, Boolean);
|
Unix Timestamp(milliseconds) |
moment().valueOf();
+moment();
|
Unix Timestamp(seconds) |
moment().unix();
|
Days in Month |
moment().daysInMonth();
|
As JavaScript Date |
moment().toDate();
|
As Array |
moment().toArray();
|
As JSON |
moment().toJSON();
|
As ISO 8601 String |
moment().toISOString();
moment().toISOString(keepOffset);
|
As Object |
moment().toObject();
|
As String |
moment().toString();
|
Inspect |
moment().inspect();
|