js和php的时间戳和时间的转化

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);
原文地址:https://www.cnblogs.com/Strive-count/p/6600243.html