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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM