求教JS时间戳转为yyyy-mm-dd hh-mm-ss格式时间的函数,,

最好是一个函数,,直接可以调用并返回一个结果的。。。
根据网上的代码写了一个,结果返回的都是Nan,,,求教,,
function time_zh(s_time){
var date = new Date(s_time);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
s_times = Y+M+D+h+m+s;
return s_times ;
}

你的这个程序没错,带入的参数应该是Sun Jun 26 2016 22:50:58这种格式,或者
06/25/2016 21:33:54这种格式的字符串
温馨提示:答案为网友推荐,仅供参考