Question: ```
 alert(new Date('2010-11-29'));

```

chrome, ff doesn't have problems with this, but safari cries "invalid date". Why ?

edit : ok, as per the comments below, I used string parsing and tried this : 

```
alert(new Date('11-29-2010')); //doesn't work in safari
alert(new Date('29-11-2010')); //doesn't work in safari
alert(new Date('2010-29-11')); //doesn't work in safari

```

**edit Mar 22 2018** : Seems like people are still landing here - Today, I would use `moment` or `date-fns` and be done with it. Date-fns is very much pain free and light as well.

Answer: 
For me the issue was I forgot to add `0` before the single digit month or day in `YYYY-MM-DD` format.  

What I was parsing: `2021-11-5`  

What it should be: `2021-11-05`

So, I wrote a little utility which converts `YYYY-M-D` to `YYYY-MM-DD` i.e. `2021-1-1` to `2021-01-01`:

```
const date = "2021-1-1"
const YYYY = date.split("-")[0];

    //convert M->MM i.e. 2->02
    const MM =
      date.split("-")[1].length == 1
        ? "0" + date.split("-")[1]
        : date.split("-")[1];

    //convert D->DD i.e. 2->02
    const DD =
      date.split("-")[2].length == 1
        ? "0" + date.split("-")[2]
        : date.split("-")[2];

    // YYYY-MM-DD
    const properDateString = `${YYYY + "-" + MM + "-" + DD}`;

    const dateObj = new Date(properDateString);

```
Arriving late to the party but in our case we were getting this issue in Safari & iOS when using ES6 back tick instead of String() to type cast

This was giving 'invalid date' error

```
const dateString = '2011-11-18';
const dateObj = new Date(`${dateString}`); 

```

But this works

```
const dateObj = new Date(String(dateString)); 

```