<script>
function get_unix_time(dateStr)
{
var newstr = dateStr.replace(/-/g,‘/‘);
var date = new Date(newstr);
var time_str = date.getTime().toString();
return time_str/1000;
}
console.log("1399479731")
console.log(get_unix_time("2014-12-31"))
console.log(get_unix_time("2015-02-08 00:22:11"))
</script>
原文:http://www.cnblogs.com/mmdrs/p/4195618.html