Fork me on GitHub
代码改变世界

js 中 时间戳转换为时间

2013-02-26 11:16  freefei  阅读(346)  评论(0编辑  收藏  举报
切记 php的时间戳 要乘以1000 changeTimeFormat(value.ctime*1000) [js] function changeTimeFormat(time) { var date = new Date(time); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); var hh = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); var mm = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); return date.getFullYear() + "-" + month + "-" + currentDate+" "+hh + ":" + mm; //返回格式:yyyy-MM-dd hh:mm } [/js]
@ https://github.com/ranmufei

守望者舆情监控

守望者舆情监控系统