PHPで指定日時で表示内容を切り替える

よく忘れてその都度調べてるのでメモ。

<?php if(strtotime(date('Y-m-d H:i')) < strtotime('2019-07-15 23:59')): ?>
  切り換え前
<?php else: ?>
  切り換え後
<?php endif; ?>

指定日まで表示(その後非表示)

<?php if(strtotime(date('Y-m-d H:i')) < strtotime('2019-07-15 23:59')): ?>
  指定日まで表示する内容
<?php endif; ?>

指定日を過ぎたら表示

<?php if(strtotime(date('Y-m-d H:i')) > strtotime('2019-07-15 23:59')): ?>
  指定日以降表示する内容
<?php endif; ?>

指定期間の間は表示

<?php if(strtotime(date('Y-m-d H:i')) > strtotime('2019-07-15 23:59') && strtotime(date('Y-m-d H:i')) < strtotime('2019-07-30 23:59')): ?>
  指定期間の間表示する内容
<?php endif; ?>

if指定の前にdate_default_timezone_set('Asia/Tokyo');があった方がいいかも。