I don't think there's a simple way, short of creating a new XSLT/Razor file and testing for your conditions and using different formats in each situation.
Whenever I've had anything that resembled special formatting that doesn't directly translate to the built-in formatting functions, I've done something like this to make sure that I'd get the same format *every* time it was needed:
<!-- Lookup variable with pre-formatted monthnames -->
<xsl:variable name="monthNamesProxy">
<month>Jan.</month> <month>Feb.</month> <month>Mar.</month>
<month>Apr.</month> <month>May</month> <month>June</month>
<month>July</month> <month>Aug.</month> <month>Sep.</month>
<month>Nov.</month> <month>Oct.</month> <month>Dec.</month>
</xsl:variable>
<xsl:variable name="months" select="msxml:node-set($monthNamesProxy)/month" />
<xsl:template match="/">
<!-- Format the publicationDate property as a date -->
<xsl:apply-templates select="$currentPage/publicationDate" mode="date" />
<!-- Format the @createDate property (attribute) as a date -->
<xsl:apply-templates select="$currentPage/@createDate" mode="date" />
</xsl:template>
<!-- Template for formatting dates -->
<xsl:template match="* | @*" mode="date">
<xsl:variable name="month" select="number(substring(., 6, 2))" />
<xsl:variable name="date" select="number(substring(., 9, 2))" />
<xsl:variable name="year" select="substring(., 1, 4)" />
<xsl:value-of select="concat($months[$month], ' ', $date, ', ', $year)" />
</xsl:template>
Format longer dates with abbreviation
I stared off using this to format an abreviated month for the date:
<umbraco:Item field="publicationDate" xslt="umbraco.library:FormatDateTime({0},'MMM. d, yyyy')" stripParagraph="true" runat="server"></umbraco:Item>
Problem is, I don't want the period for May and I'd prefer to show the full month for June and July. Any easy way to do this?
Hi Connie,
I don't think there's a simple way, short of creating a new XSLT/Razor file and testing for your conditions and using different formats in each situation.
Maybe something like this (not tested):
HTH,
Tom
Hi Connie,
Whenever I've had anything that resembled special formatting that doesn't directly translate to the built-in formatting functions, I've done something like this to make sure that I'd get the same format *every* time it was needed:
/Chriztian
is working on a reply...