Jump to content

Ipssissimus

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by Ipssissimus

  1. Thanks for your help. A little trial and error and I've resolved it. I didn't need to to have (strtotime($today) within the script only for the hard coded dates. Regards Andrew
  2. Here's the code I've updated $today = strtotime(date('dd-mm-YY')); if (strtotime($today) >= strtotime('28-10-2011') && strtotime($today) <= strtotime('24-11-2011')) {echo "<div>image1</div>";} elseif (strtotime($today) >= strtotime('25-11-2011') && strtotime($today) <= strtotime('22-12-2011')) {echo "<div>image2</div>" ;} elseif (strtotime($today) >= strtotime('23-12-2011') && strtotime($today) <= strtotime('24-02-2012')) {echo "<div>image3</div>" ;} else {echo "<div>image13</div>";} This shows image13 for today's date (22-01-2012) Many thanks Andrew
  3. Hi folks Thak you for your pointers. I have updated the variable to $today = strtotime(date('dd-mm-YY')); and added a 4 digit year to the dates within the script. I now get the "else image13". Can you offer anymore pointers please as to where I'm going wrong. Many thanks (getting balder by the minute) Andrew
  4. I'm trying to do the following PHP. I have written it in English if (today's date) => date1 AND <= date2 then {display image1} elseif (today's date) => date3 AND <= date4 then {display image2} else {display image 13} There are 24 fixed dates and 13 fixed images. I have tried using combinations of strtotime(), replacing the date value with variables, hard coding the dates within the program. I don't seem to be able to get any combination to work properly. I'm sure it's just a syntax error but I can't see it. When I've searched the web all the answers I've found relate to dates within databases but as I only have 24 dates it seems a bit of overkill. I would appreciate any pointers to the correct method I might be able to use. The dates need only a day and month as I would like this to repeat year after year. <?php $today = strtotime(date('d-m')); if (strtotime($today) >= strtotime('28-10') && strtotime($today) <= strtotime('24-11')) {echo "<div>image1</div>";} elseif (strtotime($today) >= strtotime('25-11') && strtotime($today) <= strtotime('22-12')) {echo "<div>image2</div>" ;} elseif (strtotime($today) >= strtotime('23-12') && strtotime($today) <= strtotime('24-02')) {echo "<div>image3</div>" ;} else {echo "<div>image13</div>";} ?> The result I get from this is image1 appears on the web page but I would expect image3 as today is 22-01 Thank you in advance. Andrew
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.