Forum Discussion
HowardFu
6 years agoQrew Cadet
I've used this on my own dashboard and everything is working but how do I change it so that it refreshes daily?
- AustinK6 years agoQrew CommanderGenerally it is used to update the page every few minutes or even seconds.
Out of curiosity what would be your use case for updating the page once a day? Does your data not change from the start of the day? - HowardFu6 years agoQrew CadetCorrect - the data would only change daily. However, now I want to update every hour....so same question. How would I do that?
- AustinK6 years agoQrew CommanderJust change the timeout to be an hour in milliseconds. One second = 1,000 milliseconds so one hour = 3600000 milliseconds. In the script up top just change the bolded 5000 to the number you want.
- HowardFu6 years agoQrew Cadetthank you! Just curious, if I want to do daily, do I just add a ton of zeros or can the units be changed so that they are not milliseconds.
- AustinK6 years agoQrew CommanderI'm not sure If there is a better way but yes you just have a huge number in the end if you want to do days at a time.
I think the code works well for keeping data up to date with many refreshes throughout the day but it is not the best at refreshing once a day. I'm sure you could change it but the main issue with using this to refresh once a day is the user will have to trigger the script 24 hours before it will refresh the page. So the user would have to load the page at 7am to make sure it refreshed at 7am again tomorrow. If they refresh the page manually during the day it will reset the timer to be 24 hours(or whatever you set) from that point.
Here is a good site I found for converting standard units like hours, minutes, seconds to milliseconds. http://sstut.com/javascript/convert-hours-minutes-seconds-to-milliseconds.php