javascript 时间戳 转换 为时间格式的函数
function add0(m){return m<10?'0'+m:m }
function formatymdhms(shijianchuo)
{
//shijianchuo是整数,否则要parseInt转换
var time = new Date(parseInt(shijianchuo));
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}
function formatymd(shijianchuo)
{
//shijianchuo是整数,否则要parseInt转换
var time = new Date(parseInt(shijianchuo));
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
return y+'-'+add0(m)+'-'+add0(d);
}