前提
PHPでブログサイトを作っています。
特定の日の1週間前から、特定の日の1日まで表示する条件分岐でバナーを出したいと思っているのですが、
条件分岐がうまく機能しなく困っております。
実現したいこと
以下はechoで出力できています。
echo $target_date echo date('Y-m-d', strtotime('-1 week', $target_date)); echo date('Y-m-d', strtotime('-1 day', $target_date));
$target_dateの一週間前から表示し、$target_dateの1日前で非表示とする条件を書きたいのですがどのように直せばよいでしょうか。
該当のソースコード
php
1 2if(strtotime('-1 week', $target_date) && strtotime('-1 day', $target_date)){ 3<div>バナー</div>; 4}
試したこと
以下はechoで出力して値は取得できています。
echo $target_date
echo date('Y-m-d', strtotime('-1 week', $target_date));
echo date('Y-m-d', strtotime('-1 day', $target_date));
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/10/25 03:22
2022/10/25 04:41