I need to compare dates in separate years so that I can trigger an different event in a different year, however, php doesn't recognise the comparison between the dates in different years.
Below is what i'm trying to execute;
$priceSwitchDate = date('d-m-Y',strtotime('01-01-2018'));
$dateNow = date('d-m-Y'); // currently today (in 2017)
if($dateNow >= $priceSwitchDate){ echo 'date is in 2018 change prices';}
else { echo 'date is in 2017, keep prices the same'; }
When i run the code it always seems to think that the date today (in 2017) is more than the $priceSwitchDate
(in 2018).
Any ideas why this is happening?