JS 日期与时间戳相互转化
2016-06-21 16:50
295 查看
1、日期格式转时间戳
2、时间戳转日期格式
function getTimestamp(time) { return Date.parse(new Date(time)); }
2、时间戳转日期格式
function transformPHPTime(time) { var date = new Date(time * 1000); 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(); return Y+M+D+h+m+s; }
相关文章推荐
- 常用js操作
- (概述)JavaScript权威指南笔记1
- js相关命令
- JavaScript闭包
- js调用时间显示日期为116年
- Marked - 基于JavaScript的全功能Markdown解析器
- json解析精度问题
- javascript——表单校验工具代码
- Jsp(序)
- JSTL的重点
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上
- 把多个JavaScript函数帮顶到一个onload事件处理函数上