wee493 Posted September 23, 2013 Share Posted September 23, 2013 I have 4 links that I want to show a different one every 24 hours, I would just put the links in an array and chose a random one, but it needs to be a different one every day. I'm having trouble thinking of how to do this without a mysql db Quote Link to comment https://forums.phpfreaks.com/topic/282385-show-different-link-every-24-hours/ Share on other sites More sharing options...
Solution wee493 Posted September 23, 2013 Author Solution Share Posted September 23, 2013 Sorry, I figured it out $date = date("z"); echo ($date - (4 * floor($date/4))); Quote Link to comment https://forums.phpfreaks.com/topic/282385-show-different-link-every-24-hours/#findComment-1450872 Share on other sites More sharing options...
Ch0cu3r Posted September 23, 2013 Share Posted September 23, 2013 You could use date('g'); to get current hour no? Quote Link to comment https://forums.phpfreaks.com/topic/282385-show-different-link-every-24-hours/#findComment-1450875 Share on other sites More sharing options...
requinix Posted September 23, 2013 Share Posted September 23, 2013 (edited) echo $date % 4;is much simpler than your subtraction and division. You know that's not random, right? It'll just cycle through the links in order. Today (the 23rd) would be the same image as the 19th, 15th, 11th, as well as the 27th and 1st. Edited September 23, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/282385-show-different-link-every-24-hours/#findComment-1450876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.