It's just comparing the current date to see if it falls between a set of dates...except in the code below the $start and $endDate have hardcoded years in them...I need the years to reflect the current system date year. I tried adding a variable to capture the system year and then input them into the DateTime function but PHP did not like that.
I want to keep the hardcoded day and month, just not the year...the current code will break in 2013.
Can someone help show me the proper code to accomplish this?
Code: Select all
<?
$start = new DateTime('01-01-2012'); // DD-MM-YYYY
$endDate= new DateTime('02-28-2012'); // DD-MM-YYYY
$curdate = new DateTime(date('d-m-Y'));
if ($start <= $curdate && $curdate <= $endDate) {
/*
The message below will appear if the current date is between the start and
endDate - used standards HTML to ensure that any code will not be
escaped by PHP. You can use any code here to wish to execute for the
date range.
*/
?>
<p><strong><font color="#FF0000">The time is between 1/1/2012 and 1/28/2012</font></strong></p>
<?php
// don't forget this last bit, it ends the if statement!
}
?>