Jump to content

Archived

This topic is now archived and is closed to further replies.

CodilX

Link activation on certain time?

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

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Wow, what a fast response!!

Thank you both so much, both code's are awesome

Thx - Matt

Share this post


Link to post
Share on other sites

×

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.