时间戳互转

1.  时间转换成时间戳

时间格式为2019-08-29 12:00:00

或 2019/08/29 12:00:00都可以转

var newdate = new Date(时间).getTime();     //为13位时间戳

2.时间戳转换成时间

如果是10位的时间戳

var mydate = new Date(parseInt(时间戳) * 1000);

13位时间戳

var mydate = new Date(parseInt(时间戳));

var y = mydate.getFullYear();       // 年

扫描二维码关注公众号,回复: 8525555 查看本文章

var y = mydate.getMonth();          // 月

var y = mydate.getDate();            // 日

var h= mydate .getHours();          // 时

var m= mydate .getMinutes();       // 分 

var s= mydate .getSeconds();       // 秒

发布了17 篇原创文章 · 获赞 1 · 访问量 1699

猜你喜欢

转载自blog.csdn.net/weixin_43817724/article/details/100140871