Php show info after a set date

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Php show info after a set date



Hi and thanks for taking the time to look at my question. I currently have a Php script that allows me to hide content after a set date and replace it with a default text, you can see it below:




<?php if (date('Y-m-d') <= '2018-05-30') { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php } else { ?>
<p><li><strong>The application to graduate is not available at this time.</strong> If you qualify to graduate, the Registrar’s Office will notify you when the application to graduate is available.</li></p>
<?php } ?>



What I am trying to do now is add an extra script that turns it back on in a set date so basically it functions both ways, hiding content after a set date and then activate the content once another date comes, I have been having a hard time figuring it out and I would love if you can give me a hand!



Thanks a lot for your time and your help.





What have you tried so far?
– Caddisfly
27 mins ago





I tried adding elseif but no luck so far.
– Aztlan
20 mins ago




2 Answers
2



The logic would be to add the latest date first and the earliest last. Something like:



if date >= 2018-08-30



what happens after the second date



elseif date <= 2018-05-30



What happens before the first date



else



What happens in between



This works because once a condition is fulfilled it breaks off the else/if statement.



Say, after the offer expired if you want to re-validate the offer again after 10 days from today You shall try to use,


$today = date('Y-m-d');
$datetocome = date('Y-m-d',strtotime('+10 days',strtotime($today)));

<?php if (date('Y-m-d') <= '2018-05-30') { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php }else ?>

<?php if (date('Y-m-d') <= $datetocome) { ?>
<li><p><strong>Apply to Graduate:</strong></p>
<p><a href="app-graduate-form.php" class="applyBtn">Apply to Graduate</a></p>
</li>
<?php }else{ ?>

<p><li><strong>The application to graduate is not available at this time.</strong> If you qualify to graduate, the Registrar’s Office will notify you when the application to graduate is available.</li></p>
<?php } ?>



I hope it helps.





Thank you I will try it out!
– Aztlan
2 mins ago





Is it possible to change the date of today to the end date which in this case I used 2018-05-30 as the example. So re-validate after 120 days from the date it was taken down.
– Aztlan
just now






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name