To hide Time in parts_Common_Metadata_Summary

Topics: General
Sep 13, 2011 at 9:59 AM
Edited Sep 13, 2011 at 2:38 PM

Hi friends,

I have a list.. in parts_Common_Metadata_Summary its showing Aug 20 2011 11:10 AM... but i need only Aug 20 2011..please how to hide the time..please anyone helpme.

Thanks

selva

Coordinator
Sep 13, 2011 at 9:46 PM

You can override Parts.Common.Metadata.cshtml and format the date any way you want, for example @Model.ContentPart.CreatedUtc.ToShortDateString()

Sep 14, 2011 at 2:08 PM

One interesting thing about the template for the Parts_Common_Metadata shape is that it calls out to another shape called PublishedState, and that's actually a shape method - there is no template for it. You can provide a template for it in order to override it though. Ironically, I actually demonstrate that exact scenario in the Pluralsight course that was just published yesterday (I think it's actually the very last demo in the course).

Sep 14, 2011 at 2:12 PM

I should add ... it's really quite simple. Just place a template called PublishedState.cshtml in the Views folder of your theme. You can do whatever you want with the datetime in there (the model will have 2 DateTime properties called "createdDateTimeUtc" and "publisheddateTimeUtc").

Or you can completely remove the call to @Display.PublishedState in the Parts.Commom.Metadata.cshtml template as Bertrand said, and format the date in there based off the ContentPart property of the model.