首页 > 编程语言 > 详细

javascript中的小技巧

时间:2014-12-31 14:23:58      阅读:244      评论:0      收藏:0      [点我收藏+]

字符串转日期对象

 

<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>

 

  

 

  

 

javascript中的小技巧

原文:http://www.cnblogs.com/mmdrs/p/4195618.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!