2013-05-13 28 views
-1

我希望有人能幫助我。鏈接在某些時間之間可見

我需要一個鏈接,在特定時間之間可見,例如晚上6點,&凌晨1點。在我的網站上註冊的客戶可以更改其管理面板中的商店開啓和關閉時間,並將其連接到數據庫中的表格。

該鏈接只能在客戶通過控制面板確定的指定時間內顯示。在這些小時之外,鏈接被隱藏/不可見,不可點擊。

所以這需要從每個客戶的數據庫表中調用/回顯時間。

任何幫助將是偉大的。 非常感謝

馬克

+1

您的問題比較普遍,你可能想分享你所擁有嘗試和你卡住的地方。 – 2013-05-13 23:30:04

回答

0

試試這個:

// Assuming $userMin and $userMax are the users specified times 
$time = date('H'); 
if($time > $userMin && $time < $userMax) { 
    echo "<a href='linkUrl'>Description</a>"; 
} 
1

你可以使用類似...

// check if the date (current hour) is between two times, 
// if it is, assign the link to $link, else assign nothing to $link 
$link = date('H') >= 6 && date('H') <= 20 ? '<a href="#">Link</a>' : ''; // replace hardcoded hours with vars if needed 
echo $link;