• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Locked until correct date

New Here ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Is there a simple/easy way to lock links/pages until a spesific date? I'm making an advent/christmas calendar for my school, and am not able to do it manually this year.

Views

117

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Can you use php on your website/server?

 

If you can you can access the 'current date' and check it against the date when you require the links/information to be shown.

 

Below is an example - 16th and 17th November will show the information but 18th and 19th will not as those dates have not been reached yet.

 

 

<?php
$currentDate = date('Y-m-d');
?>

<?php if($currentDate >= '2020-11-16') { ?>
<h3>16-11-2020 Show Information</h3>
<?php } ?>


<?php if($currentDate >= '2020-11-17') { ?>
<h3>17-11-2020 Show Information</h3>
<?php } ?>

<?php if($currentDate >= '2020-11-18') { ?>
<h3>18-11-2020 Show Information</h3>
<?php } ?>

<?php if($currentDate >= '2020-11-19') { ?>
<h3>19-11-2020 Show Information</h3>
<?php } ?>

 

 

 

If you want to show the links on the page but deny access to the associated pages until a specific date then you could do something like below: Create a default 'sorry.html' page which will be evoked IF the specific date has not yet been reached. Create a page for each date '16-11-2020.html', '17-11-2020.html' etc which will be evoked IF the date is equal or more than the current date:

 

<?php
$currentDate = date('Y-m-d');
?>


<ul>

<li><a href="<?php if($currentDate >= '2020-11-16') { echo '16_11_2020.html'; } else { echo 'sorry.html';} ?>">16-11-2020</a></li>

<li><a href="<?php if($currentDate >= '2020-11-17') { echo '17_11_2020.html'; } else { echo 'sorry.html';} ?>">17-11-2020</a></li>

<li><a href="<?php if($currentDate >= '2020-11-18') { echo '18_11_2020.html'; } else { echo 'sorry.html';} ?>">18-11-2020</a></li>

<li><a href="<?php if($currentDate >= '2020-11-19') { echo '19_11_2020.html'; } else { echo 'sorry.html';} ?>">19-11-2020</a></li>

</ul>

 

 

However if gets a bit more complex if you produce seperate pages because if someone typed in 18-11-2020.html directly before the date is reached the page would be accessible so you would have to nail that down: One way would be to check the date on each seperate page '16-11-2020.html', '17-11-2020.html' etc - show the information only IF the date is equal or more than the current date or show a message IF its not.

 

<?php
$currentDate = date('Y-m-d');
?>


<?php if($currentDate >= '2020-11-18') { ?>

<h3>Access Allowed</h3>

<?php } else { ?>

<h3>No Access Allowed</h3>

<?php } ?>

 

 

Its a matter of finding a solution which you understand - you could do all the processing in one page if you have the necessary knowledge.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

LATEST

Thank you so very much. I will try out this in a few days, and see if i can make it work. Not that I'm not eager  to try it right away, but they won't let me leave the hospital until Friday 🤣😂 Tibe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines