「JS」php时间戳在js中转格式(函数)
目标格式:YYYY-MM-SS HH:mm:ss
function for_php_date_to_str(timestamp)
{
update=new Date(timestamp*1000);//时间戳要乘1000
year=update.getFullYear();
month=(update.getMonth()+1<10)?('0'+(update.getMonth()+1)):(update.getMonth()+1);
day=(update.getDate()<10)?('0'+update.getDate()):(update.getDate());
hour=(update.getHours()<10)?('0'+update.getHours()):(update.getHours());
minute=(update.getMinutes()<10)?('0'+update.getMinutes()):(update.getMinutes());
second=(update.getSeconds()<10)?('0'+update.getSeconds()):(update.getSeconds());
return (year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second);
}