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 Link to comment https://forums.phpfreaks.com/topic/282385-show-different-link-every-24-hours/ Share on other sites More sharing options...
wee493 Posted September 23, 2013 Author Share Posted September 23, 2013 Sorry, I figured it out $date = date("z"); echo ($date - (4 * floor($date/4))); 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? 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 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. 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
Archived
This topic is now archived and is closed to further replies.