Format a datetime field

Jan 3, 2015 at 12:57 AM
I have a DateTime field in a content type, and @content.MyField produces: 12/1/2014 12:00:00 AM

I'd like to produce "December 1, 2014" ... so how do I do this easily?
Jan 3, 2015 at 11:48 AM
@content.MyField is of type DateTime. so you have to convert it to a string.

A DateTime has a property 'Date' which provides you some convert-to-string methods.

since @content.MyField is dynamic you might loose intellisense so use a typed datetime in your template to play around.
        var myDate = DateTime.Now;

        @myDate.Date.ToString("dd MMM yyyy");
         //@content.MyField.Date.ToString("dd MMM yyyy");
about formatsyntax:

hope this helps a little bit.

Marked as answer by jncraig on 1/4/2015 at 9:32 AM
Jan 4, 2015 at 4:32 PM