美文网首页
js 时间转时间戳

js 时间转时间戳

作者: F的平方 | 来源:发表于2020-09-23 18:59 被阅读0次

 //时间转时间戳

            timeToUnix(string) {

                var f = string.split(' ', 2);

                var d = (f[0] ? f[0] : '').split('-', 3);

                var t = (f[1] ? f[1] : '').split(':', 3);

                return (new Date(

                    parseInt(d[0], 10) || null,

                    (parseInt(d[1], 10) || 1) - 1,

                    parseInt(d[2], 10) || null,

                    parseInt(t[0], 10) || null,

                    parseInt(t[1], 10) || null,

                    parseInt(t[2], 10) || null

                    )).getTime() / 1000;

             },

相关文章

网友评论

      本文标题:js 时间转时间戳

      本文链接:https://www.haomeiwen.com/subject/qewoyktx.html