psquillace Posted January 13, 2010 Share Posted January 13, 2010 Hello All, I worte this bit of code so that a few graphics I have online will change if in between 2 dates. It goes something like this: <?php if(time() > strtotime('1262930400') && time() < strtotime('1263427199')){ echo ('<tr><td align="center" valign="middle" colspan="2"><a href="http://www.raffledrums.com/acrylic-raffle-drums.htm"><img src="images/raffledrums_tn.jpg" border="0" hspace="0" vspace="5" width="238" height="98" alt="Giant Raffle Drums"></a></td></tr>'); }else{ echo ('<tr><td align="center" valign="middle" colspan="2"> </td></tr>'); } ?> However, it is not working correctly. Am I doing something wrong in there that I am missing? Thanks for the help and or advice on this, Paul Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/ Share on other sites More sharing options...
mikesta707 Posted January 13, 2010 Share Posted January 13, 2010 what are those times in the strtotime() function supposed to be exactly? have you tried putting dashes or some other delimiter between the year/day/month? Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/#findComment-994432 Share on other sites More sharing options...
psquillace Posted January 13, 2010 Author Share Posted January 13, 2010 Hi Mike, those are supposed to be Unix Times in Seconds. I tested it by doing an echo time() function. It gave me the date and time in seconds. Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/#findComment-994433 Share on other sites More sharing options...
laffin Posted January 13, 2010 Share Posted January 13, 2010 strtotime takes a date format string, and converts it to time format. if you already have the time, than there is no need to convert. those strings should be just numbers (int) if(time() > 1262930400 && time() < 1263427199){ Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/#findComment-994436 Share on other sites More sharing options...
ignace Posted January 13, 2010 Share Posted January 13, 2010 Please note that if(time() > 1262930400 && time() < 1263427199){ Will only work only once that is between 1262930400 and 1263427199. Once it exceeds 1263427199 it will never be shown again. Is this what you are looking for? Or is it more something like this if (date('H', time()) == 15 && date('H', time()) < 18) { .. Which displays something during a certain part of the day? Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/#findComment-994438 Share on other sites More sharing options...
psquillace Posted January 13, 2010 Author Share Posted January 13, 2010 Ahhh... Thanks guys for all the tips on this, I got it to work.. only took me 5hrs. LOL Paul Quote Link to comment https://forums.phpfreaks.com/topic/188370-graphic-change-based-on-date-span/#findComment-994447 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.