JS 中2015年04月07日日期格式怎么转换成时间戳格式

2015年04月07日 转到12345679987的时间戳格式

function get_unix_time(dateStr)
{
    dateStr = dateStr.replace('年','-');
    dateStr = dateStr.replace('月','-');
    dateStr = dateStr.replace('日','-');
    var newstr = dateStr.replace(/-/g,'/'); 
    var date =  new Date(newstr); 
    var time_str = date.getTime().toString();
    return time_str.substr(0, 10);
}

get_unix_time("2015年04月07日");

温馨提示:答案为网友推荐,仅供参考
相似回答