您的位置:首页 > Web前端 > JavaScript

js把日期字符串转换成时间戳

2017-07-11 18:23 316 查看
dateStr格式为“2014-05-08 00:22:11 ”

function get_unix_time(dateStr)

{

    var newstr = dateStr.replace(/-/g,'/'); 

    var date =  new Date(newstr); 

    var time_str = date.getTime().toString();

    return time_str.substr(0, 10);

}

转载地址:http://blog.sina.com.cn/s/blog_97688f8e0101wmha.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: