function addZeroForTime(val) {
return val < 10 ? '0' + val : val;
}
function formatDateTime(ts) {
var now = new Date(ts);
var year = now.getFullYear();
var month = addZeroForTime(now.getMonth() + 1);
var date = addZeroForTime(now.getDate());
var hour = addZeroForTime(now.getHours());
var minute = addZeroForTime(now.getMinutes());
var second = addZeroForTime(now.getSeconds());
return year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second;
}