This project is read-only.

How to remove time from Date Time stamp

Topics: Customizing Orchard, General, Troubleshooting
Jun 7, 2011 at 12:44 PM


I am new to Orchard and MVC, i have been playing around to see if i can remove the time from the date time stamp for blog posts, but i'm getting a bit confused as to where the code is to ammend the date time format,

I have found this file Core/Common/Views/Parts.Common.Metadata.cshtml and can see a string that relates to the date but cant work out how to change it, i know i can use "{0:d}" but i cant find the part that renders this beneath the blog post? i also cant find the model for this?

can anyone kindly point me in the right direction?

Many thanks


Jun 7, 2011 at 1:36 PM

First, you need to enable the Shape Tracing feature. It adds a toolbar at the bottom of the page, which can be used to explore all the template components of the page so you can see exactly which "shapes" are responsible for rendering different parts of the page.

Now, that published date/time is a bit weird in how it renders, because its actually happening from code. You can still override the template tho.

In Parts.Common.Metadata there isn't a string relating to the date. What's happening is that it chains into rendering another shape called "PublishedState" - and it's passing in the created and published dates from the dynamic model. They're DateTimes, not Strings ;)

The PublishedState shape is defined in Orchard.Core\Common\Shapes.cs - it's a method that generates a template from code. But if you create your own template called PublishedState.cshtml and add it to your theme, it'll override the core shape.