将时间戳转换成日期格式:
// 简单的一句代码
var date = new Date(时间戳); //获取一个时间对象 注意:如果是uinx时间戳记得乘于1000。比如php函数time()获得的时间戳就要乘于1000
/*----------下面是获取时间日期的方法unix时间戳转换成时间 c中国linux,需要什么样的格式自己拼接起来就好了----------*/
date.getFullYear();//获取完整的年份(4位,1970)
date.getMonth();//获取月份(0-11,0代表1月,用的时候记得加上1)
date.getDate();//获取日(1-31)
date.getTime();//获取时间(从1970.1.1开始的毫秒数)
date.getHours();//获取小时数(0-23)
date.getMinutes();//获取分钟数(0-59)
date.getSeconds();//获取秒数(0-59)
// 例子unix时间戳转换成时间 clinux社区,比如需要这样的格式:yyyy-MM-dd hh:mm:ss
var date = new Date(90);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
console.log(Y+M+D+h+m+s); //呀麻碟