Run code once a day

后端 未结 3 1513
南旧
南旧 2020-12-06 14:45

I was just wondering if it is possible to have a javascript for loop that only iterates through the loop once a day i.e. when the date changes?

for(i=0; i &l         


        
3条回答
  •  半阙折子戏
    2020-12-06 15:28

    the best way to achieve it is by creating a cookie that lasts for1 day.. Even if after the refresh of the web page or browser gets closed that countdown will still continue..

    setcookie($cookie_name, $cookie_value, time() + 86400, "/"); 
    

    This means 86400 = 1 day

    Hope it helps

提交回复
热议问题