Jump to content

Link activation on certain time?


CodilX

Recommended Posts

Hi everyone,

I'm new to the forums, hope to recieve some help on code I'm trying to put together :)

Basicly I want a link, that would work from 10pm to 6am. I'm trying to do it with array's, but with no luck :( Can somebody help me with that?

Thx, Matt
Link to comment
Share on other sites

What do you mean exactly? You want the link to appear between 10pm to 6am?
If that what you want, try this:

[code]
<?php
$hour=date(G); //Get the hour (numbers 0-23)
$display_link=TRUE;
if($hour<22 && $hour>5){$display_link=FALSE;}; //If the time is between 6am to 10pm set $display_link to false

if($display_link){echo('<a href="page.php">Click here</a>');}; //If $display_link is set on true, display the link.
?>
[/code]

Assuming that's what you asked for.

Orio.
Link to comment
Share on other sites

i am learning php but also trying to help good luck.

my example but $time_from from database set at 10.00.00
and time to set in database as $time_to 18.00.00.
[code]
<?
$time_from="10.00.00";
$time_to="18.00.00";

if ($time_to - $time_from) {

echo "<a href='http://www.google.com'>google link</a>";

}else {

echo "sorry wrong time";

}

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.