How to change Icon if within 7 day else will change another icon by PHP
Get the solution ↓↓↓can ask how to change the icon if it is within 7 days else will change another icon? and this is my code
<?php
foreach($getEventList as $key => $value){
$venue = $value['acd_schd_venue'];
$title = $value['ach_name'];
$date = $value['acd_schd_date'];
$StartTime = $value['acd_start_time'];
$EndTime = $value['acd_end_time'];
$createdDate = date("Y-m-d", strtotime($value['acd_created_date']));
$add7Day = date('Y-m-d', strtotime($value['acd_created_date']. ' + 8 days'));
if( $createdDate > $add7Day ) {
echo '<span><img src="' . $image2 . '" /></span>';
}else{
echo '<span><img src="' . $image . '" /></span>';
}
}
Answer
Solution:
The php date() funtion will return a string. So your if statement will not work. strtotime() will return a unix timestamp wich can be used in a if statement to compare.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type bool in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.