How can I change the date format of a DateTime object?

 

Dear all,

I would like to change the display format of x.PublicationDate which is of type DateTime in following manner:

From: 2/28/2013 12:00:00 AM

To: 28.02.2013

My current code (using MVC 4):  @Html.PropertyFor(x => x.PublicationDate)

Thank you in advance!

Best regards;

Daniel

#66032 Feb 18, 2013 17:41
  • Stefan Forsberg
    Member since: 2007
     
    #66033 Feb 18, 2013 17:53
  • Petter Klang
    Member since: 2008
     

    I'm guessing you get that format because of your applications culture setting.

     

    But you could change the layout for how you wish to render DateTimes. Joel did a good post on the subject.

    #66040 Feb 18, 2013 20:21