Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add seconds to date

var dbDate = '2013-11-15 12:51:18';
var seconds = 30;


var parsedDate = new Date(Date.parse(dbDate))
var newDate = new Date(parsedDate.getTime() + (1000 * seconds))


console.log(formatDate(newDate))


function formatDate(date){
    return ('{0}-{1}-{3} {4}:{5}:{6}').replace('{0}', date.getFullYear()).replace('{1}', date.getMonth() + 1).replace('{3}', date.getDate()).replace('{4}', date.getHours()).replace('{5}', date.getMinutes()).replace('{6}', date.getSeconds())
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #seconds #date
ADD COMMENT
Topic
Name
6+1 =