what is the best way to do something , like inserting an element at a certain time of the day ? should I use setTimeout() os is there a better way to do it ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
setTimeout() and setInterval() both execute timed js statements in relation to when they were loaded, not at a specific time each day, so they don’t seem like a clean solution. You could throw a bit of server-side scripting in there. Some random solutions plucked from my tired brain:
Obviously not great if you want to keep everything client-side… 🙂
EDIT
To execute a statement in php between 1pm and 2pm every day (untested):