Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Scheduled Task in JavaScript

I am creating an application in javascript which send notification on every sunday 12.00 am.
What should I do to call a function on that time.

like image 363
Avin Avatar asked Dec 17 '22 00:12

Avin


1 Answers

I wouldn't do it with javascript

That said(with shouting...)

function foo(){
    var day =new Date().getDay();
    var hours =new Date().getHours();
    
    if (day === 0 && hours >12 && hours < 13)  // day is a 0 index base
                                               // sunday between 12:00 and 13:00
        // Do what you want here:
}

setInterval(foo, 3600000); // one hour check.

Live DEMO

like image 57
gdoron is supporting Monica Avatar answered Jan 03 '23 04:01

gdoron is supporting Monica