js字符串转Date类型

原帖地址:http://www.cnblogs.com/sufei/archive/2012/11/10/2764035.html

function getDate(strDate) {    
          var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,    
           function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');    
          return date;    
      }


发布了87 篇原创文章 · 获赞 22 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/gaofenglxx/article/details/54580227