js時間戳轉化為時間
//時間戳轉時間 function time(sj) { var now = new Date(sj*1000); var year =now.getFullYear(); var month =now.getMonth()+1; var date =now.getDate(); var hour =now.getHours(); var minute =now.getMinutes(); var second =now.getSeconds(); return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; } alert(time(1404610908));
彈出的日期是2014-7-6 9:41:48
php獲取時間戳
$shijian = time();
將時間戳轉化為時間
$time = date("Y-m-d H:i:s",$shijian);