var date = new Date();
formatTime(date);
function formatTime(date){
var year = date.getFullYear();
var month = "0"+(date.getMonth()+1);
var day = "0"+date.getDate();
var hour ="0"+ date.getHours();
var minutes = "0" + date.getMinutes();
var second ="0"+ date.getSeconds();
return year+'-'+month.substr(-2)+'-'+day.substr(-2)+' '+hour.substr(-2)+':'+minutes.substr(-2)+':'+second.substr(-2);
}