Medeiros
Medeiros

Reputation: 38

Format a Date Time to the Full date/time pattern (short time) in Orchard

Within Orchard CMS (version 1.6) I have a Query that displays a DateTime property called StartDate. When setting it up I chose the "Full date/time pattern (short time)" as the Date format, and then I was rewriting the output as follows:

<My html text here> {Text}

This would render as "My html text here Saturday, April 13, 2013 2:30 PM".

I realized that for users on a different time zone, the date/time was being converted automatically and instead of displaying 2:30 PM (server is at PST), it was displaying 5:30 PM (user was at EST).

Following Bertrand Le Roy's solution here, it worked out nice with one minor issue.

Now my code is this:

<My html text here> {Content.Fields.MyContentType.MyDateTimeField.DateTime.Local}

And here is the result: "My html text here 4/13/2013 2:30:00 PM".

The formatting is not the one I would rather use.

Does anyone know how can I format this to the Full date/time pattern (short time)?

Thank you in advance.

Upvotes: 0

Views: 1146

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

{Content.Fields.MyContentType.MyDateTimeField.DateTime.Local.Format:dddd, MMMM d, yyyy h:mm tt} should do the trick.

Upvotes: 2

Related Questions