Posts

Showing posts with the label set interval in js with time

How to use set interval in Javascript

set interval in js setInterval(function google(){ console.log("Hello world") //2000 is millisecond it means this program print hello world every 2 second } , 2000) Try other set interval code with a function call setInterval(function google(){ //call other function whatever you want to execute intervalcall() } , 2000) function intervalcall(){ console.log("Hello Fellow user") } Try other set interval code with a time to start trigger setInterval(function google(){ if(new Date().getSeconds() == 20){ //In case date in minute you use "new Date().getMinutes" //In case date in hours you use "new Date().getHours()" console.log("Hello Fellow users, trigger on 20 seconds") } }, 1000)