Home > database >  Daily info using setTimeout?
Daily info using setTimeout?

Time:02-28

How can I use setTimeout to display a new Text daily, every 24 hours The code below is wrong It's just to draw attention to the images I want to display enter image description here

CodePudding user response:

Dont use setTimeout function if you want to show quotes daily because when you will close your application then setTimeout will vanished as it will not run in background or when you will reload App then it will also reset. So its not good practice to use it for that purpose. If you want to show random quotes daily then make a backend and here you have to write CRON Job for it which will be executed after 24 hours and save quotes in your DB. And then load these quotes (by making backend route) from your DB on client side. However if you want to use the background timers then use them instead of setTimeout.

  • Related