HughbertD Posted December 28, 2007 Share Posted December 28, 2007 Hi Sorry for the obvious simplicity of this question How would I go about creating a snippet of code that works out if the current date is between two variable dates $start and $end? Quote Link to comment https://forums.phpfreaks.com/topic/83472-solved-php-date-question/ Share on other sites More sharing options...
HughbertD Posted December 28, 2007 Author Share Posted December 28, 2007 Sorry - here is my current attempt <?php $startdate = mktime(0,0,0,date("m"),date("d")-7,date("Y")); echo(date ("Y/m/d", $startdate)); ?><br> <?php $enddate = mktime(0,0,0,date("m"),date("d")+7,date("Y")); echo(date ("Y/m/d", $enddate)); ?><br> <?php echo (date("Y/m/d")); if (date > $startdate && date < $enddate) { echo ("STUFF"); } else echo ("<br>LAMO"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83472-solved-php-date-question/#findComment-424670 Share on other sites More sharing options...
Dane Posted December 28, 2007 Share Posted December 28, 2007 <?php $startdate = mktime(0,0,0,date("m"),date("d")-7,date("Y")); //echo date("Y/m/d", $startdate); $enddate = mktime(0,0,0,date("m"),date("d")+7,date("Y")); //echo date("Y/m/d", $enddate); $now = mktime(0,0,0,date("m"),date("d"),date("Y")); if ($now > $startdate && $now < $enddate) { echo ("STUFF"); } else { echo ("LAMO"); } ?> Try this Quote Link to comment https://forums.phpfreaks.com/topic/83472-solved-php-date-question/#findComment-424678 Share on other sites More sharing options...
HughbertD Posted December 28, 2007 Author Share Posted December 28, 2007 Superb. I love you Quote Link to comment https://forums.phpfreaks.com/topic/83472-solved-php-date-question/#findComment-424687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.