Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
 
PREVIOUS NEXT
Tagged: #add #hours #string #date #javascript
ADD COMMENT
Topic
Name
6+5 =