I want to execute a script at a specific time. How do I get something like this to work?
var future = moment().add('1', 'm').format()
if (moment().format() == future) {console.log('Whatsapp')}
I want to execute a script at a specific time. How do I get something like this to work?
var future = moment().add('1', 'm').format()
if (moment().format() == future) {console.log('Whatsapp')}
Get the time difference between now and the specific time in the future. Set a timeout:
const future = moment().add('5', 's');
const now = moment();
setTimeout(() => { console.log('Whatsapp'); }, future.diff(now));
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.1/moment.min.js"></script>