//js时间戳格式化成日期格式
function dateformat(timestamp,chinese){
if (!timestamp){
datetime = new Date().toLocaleString();
}else{
datetime = new Date(parseInt(timestamp)*1000).toLocaleString();
}
if (!chinese){
return datetime.replace(/年|月/g, '-').replace(/日/g, '');
}
return datetime;
function dateformat(timestamp,chinese){
if (!timestamp){
datetime = new Date().toLocaleString();
}else{
datetime = new Date(parseInt(timestamp)*1000).toLocaleString();
}
if (!chinese){
return datetime.replace(/年|月/g, '-').replace(/日/g, '');
}
return datetime;
}
example:
datetime = dateformat();
alert(datetime);