how to subtract db time from real time


I have this:

let minute = timeSplit[0]
                let today = new Date();
                    if (Math.abs(today.getMinutes() - Number(minute)) <= 5) {
                        client.messages.create({
                                to: userPhoneNumber,
                                from: '12055578708',
                                body: 'hello ' + userNameString + ', nYour training session just finished with ' + trainerNameString
                            }, function(err, data) {
                                if (err) {
                                    console.log("err: " + err)
                                }
                                console.log(data)
                            });
                    } else {
                        console.log("not working")
                    }

what it does is gets the current minute (ex. 54th minute of the hour), and subtract it from the minute that is in my database. If my db minute is within 5 minutes of the current minute, then do the next part.

However, in my db is both minute and hour. i need to check if the time in my db is within 5 minutes of the current time. minute and hour are both just string values. How can i do this?

Source: JavaSript – Stack Overflow

November 3, 2021
Category : News
Tags: if-statement | javascript | logic | node.js | twilio

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.