Answers for "add 24 hours to string date javascript"

3

add 24 hours to string date javascript

const stringData = "2022-05-06";
// add 24 hours
let newDate = new Date(new Date(stringData).getTime() + 60 * 60 * 24 * 1000)
console.log(newDate) // 2022-05-07T00:00:00.000Z
//add 23 hours and 59 minutes
let nDate = new Date(new Date(stringData).getTime() + 60 * 60 * 24 * 1000 - 1)
console.log(nDate) // 2022-05-06T23:59:59.999Z
Posted by: Guest on May-06-2022

Code answers related to "add 24 hours to string date javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language