用js转换时间戳为日期格式

(1):转换成 2011-3-16 16:50:43 格式:
 

  1. function getDate(tm){ 
  2. var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " "
  3. return tt; 


 

(2):转换成 2011年3月16日 16:50:43:

  1. function getDate(tm){ 
  2. var tt=new Date(parseInt(tm) * 1000).toLocaleString() 
  3. return tt; 



(3):转换成 2011年3月16日 16:50
 

    1. function getDate(tm){ 
    2. var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16); 
    3. return tt; 
posted @ 2013-08-21 13:35  编程狂热者  阅读(217)  评论(0编辑  收藏  举报