How to increase 10
seconds in JavaScript query in the following date format.
My date is: 2020-04-30 16:51:42
My expected output is: 2020-04-30 16:51:52
How to increase 10
seconds in JavaScript query in the following date format.
My date is: 2020-04-30 16:51:42
My expected output is: 2020-04-30 16:51:52
You can use Date.setSeconds() method to set the seconds.
Look at this link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds
You can use this code
var d = new Date("2020-04-30 16:51:42");
d.setSeconds(d.getSeconds()+10);
console.log(d);
Better idea is convert to millis long number and add (10 * 1000)
var d = new Date("2020-04-30 16:51:42");
var mil = d.getTime();
mil = mil + (10 * 1000)
console.log(new Date(mil));
1000
millisecond = 1
second
For Safari browser this format will work
var d = new Date("2020/04/30 16:51:42");