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

来源:互联网 发布:淘宝实名认证小号 编辑:程序博客网 时间:2024/05/20 06:07
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