Question: In mvc4 application I used datetime format `dd.MM.YYYY HH:mm`

*EditorTemplates > DateTime.cshtml*

```
@Html.TextBoxFor(model => model, "{0:dd.MM.yyyy HH:mm}", ViewData["htmlAttributes"])

```

and I parsed it like this

```
DateTime.ParseExact(myDate, "dd.MM.yyyy", CultureInfo.InvariantCulture);

```

where myDate is passed as parameter ofcourse.

Inside jquery datetime picker I used code (abbreviated inside function)

```
... format('DD.MM.YYYY HH:mm')

```

how can I change this code to use following datetime format

```
 2016-04-04 23:05

```

I tried with

```
@Html.TextBoxFor(model => model, "{0:YYYY-MM-DD HH:mm}", ViewData["htmlAttributes"])

```

and parsing like

```
DateTime.ParseExact(myDate, "YYYY-MM-DD", CultureInfo.InvariantCulture)

```

and inside js 

```
... format('YYYY-MM-DD HH:mm')

```

but I'm getting year as `YYYY` instead of `2016`.

Answer: 
[Custom Date and Time Format Strings](https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx) are case sensitive. There is no `YYYY` or `DD` as a specifiers. That's why those strings will be in *as* they are when you get it's string representation.

From docs;

> 
> Any other character.
> 
> 
> The character is copied to the result string unchanged.
> 
> 
> 

Your format should be as `yyyy-MM-dd`.
Try it with `"yyyy-MM-dd"` instead of `"YYYY-MM-DD"`.