2009/07/23

[PHP] 期間内に指定日が入っているかテストする関数

// $testdayが期間内($startday~$finishingday)か調べる。
// $testday省略時は本日
function checkperiod ($startingday, $finishingday, $testday = null)
{
  if (!$testday) $testday = time();

  return strtotime ($startingday) < $testday && $testday < strtotime ($finishingday) ? true : false;
}

0 件のコメント:

色々な画像ファイル形式をhtmlに埋め込む(PHP)

画像をhtmlに埋め込む際、単一の場合は img/src、複数の拡張子を指定すると img/source/srcsetに展開してくれる便利関数。また、単一拡張子のみが指定されている場合は、ブラウザのサポート状況に応じ、avifやwebpの拡張子を持つ同名のファイルがある場合は[a...