inLastYear()

更新日: 2018-09-14

is.inLastYear(value:date)

渡された日付が今日から1年前までの期間内かどうかを判定します。

インターフェース:
not
var twoMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 2));
var thirteenMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 13));
is.inLastYear(twoMonthsAgo);
=> true

is.inLastYear(thirteenMonthsAgo);
=> false

is.not.inLastYear(thirteenMonthsAgo);
=> true

デモ

変数を判定してconsole.logを出力します。

JavaScript
var val   = new Date(new Date().setMonth(new Date().getMonth() - 2));
if (is.inLastYear(val)) {
  console.log('2ヶ月前は1年前までの範囲内です。');
}


© 2014-2016 Aras Atasaygin Released under the MIT license

このコンテンツはAras Atasaygin(arasatasaygin)によるis.jsドキュメントを翻訳/改変したものです。