---
title: "js字符串转日期格式"
author: "boss5518831534"
date: "2013-03-01T12:06:04Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2013-03-01T12:06:04Z"
id: 1819747
url: "https://garson.iteye.com/blog/1819747"
---

//字符串转日期格式，strDate要转为日期格式的字符串

        function getDate(strDate) {

            var date = eval('new Date(' + strDate.replace(/\\d+(?=-\[^-]+$)/,

             function (a) { return parseInt(a, 10) - 1; }).match(/\\d+/g) + ')');

            return date;

        }