Momentjs-is-same-or-before

提供:Dev Guides
移動先:案内検索

MomentJS-以前と同じ

このメソッドは、ある瞬間が同じであるか、別の瞬間の前かをチェックします。

構文

moment().isSameOrBefore(Moment|String|Number|Date|Array);
moment().isSameOrBefore(Moment|String|Number|Date|Array, String);

var issameorbefore = moment('2017-10-10').isSameOrBefore('2017-11-21');

出力

var issameorbefore = moment('2017-10-10').isSameOrBefore('2017-08-21');

出力

isSameOrBefore

上記のコードでは、モーメントは同じでも以前でもないため、出力はfalseです。

isSameOrBefore()で単位を使用でき、サポートされる単位は年、月、週、日、時間、分、秒です。

var issameorbefore = moment('2017-10-10').isSameOrBefore('2017-08-21', 'year');

出力

isSameOrBeforeメソッド

var issameorbefore = moment('2017-10-10').isSameOrBefore('2017-10-21', 'month');

出力

isSameOrBefore Month