I have the following code in the page template but don't know how to format ReleaseDate
to display full month and year e.g. October 2016. Please help!
<ul class="icon-list">
<cms:CMSWebPartZone ZoneID="ZoneLinks" runat="server" />
<li class="date inline">Published: <%= CurrentDocument.GetValue("ReleaseDate") %></li>
</ul>
In a different transformation, I have this <%# GetDateTime("ReleaseDate", "MMMM yyyy") %>
and it works, but I don't know how to use it in the above context. I have tried CurrentDocument.GetDateTime(....)
, but didn't work.
You can't use transformation methods outside transformations. However, you can use vanilla .NET approach:
<%= ((DateTime)CurrentDocument.GetValue("ReleaseDate")).ToString("MMMM yyyy") %>
Make sure you apply a null check if ReleaseDate
can be null.