function formatDate(timestamp){ var test = new Date(parseInt(timestamp) * 1000); var $year = test.getFullYear(); var $month = parseInt(test.getMonth())+1; var $day = test.getDate(); //返回格式一 var f_date1 = $year+"-"+$month+"-"+$day; return f_date1; //返回格式二 var f_date2 = $year+"年"+$month+"月"+$day+"日"; return f_date2; } var stmp = '1456816515'; formatDate(stmp);