时间戳转换为日期格式
2018-04-03 14:54
405 查看
如何把长度13位的时间戳转换为这样的格式:2017-04-23 18:55:49
function getTime(t)//t是要转的13位时间戳 var date = new Date(t); 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;}希望大家有什么意见或建议,可以指出
function getTime(t)//t是要转的13位时间戳 var date = new Date(t); 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;}希望大家有什么意见或建议,可以指出
相关文章推荐
- SQL Server日期时间格式转换字符串
- 日期转换 NSDate 格式 格林尼治时间 时差
- SQL Server日期时间格式转换字符串详解
- 用js将从后台得到的时间戳(毫秒数)转换为想要的日期格式
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换
- SQL Server日期时间格式转换字符串
- 时间戳、日期格式、以及相互转换
- js 时间戳 与 字符串 和 日期格式 的转换
- java中日期时间格式与毫秒数的转换如何将指定时间转换为Date类型
- Java转换Json日期/Date(1487053489965+0800)/格式以及js时间格式 Tue Feb 14 2017 14:06:32 GMT+0800
- Java时间日期格式的转换
- php中时间戳和日期格式的转换
- 时间戳转换日期格式/字符串与日期格式的转换
- php UNIX时间戳转换为指定日期格式
- SQL Server日期时间格式转换字符串详解
- Java将Unix时间戳转换成指定格式日期
- mysql 时间戳与日期格式的相互转换
- mysql获取日期(将时间戳转换成短日期格式)
- 将日期时间转换为指定格式
- 将字符串转换为日期和时间,或日期转换为字符串格式