Search

I am having trouble with the utility Format Date/Time. All I want is to take a date from a regular date field and show it on the page in any other format than 2013-01-02. Using this utility like this:

<xsl:call-template name="format-date">
     <xsl:with-param name="date" value="'2005-12-01'" />
</xsl:call-template>

I get NaNth. If I send a simple format like 'Y' or 'M' or 'y' - I get nothing. Am I using this utility that wrong? I cannot find any examples of how to call it.

Is there some other way? This cannot be an uncommon task. All I want is to turn 2013-01-02 into January 2nd, 2013.

Thanks for reading.

You are missing the format param:

<xsl:call-template name="format-date">
    <xsl:with-param name="date" value="'2005-12-01'"/>
    <xsl:with-param name="format" value="'M D, Y'"/>
</xsl:call-template>

Thanks @thebestsophist, but from the documentation the 'format' parameter is optional. I also mentioned that I had tried with the format parameter set to 'Y', 'M', and 'y' and gotten no result. If I try your example I also get nothing.

|<xsl:call-template name="format-date">
    <xsl:with-param name="date" value="'2005-12-01'"/>
    <xsl:with-param name="format" value="'M D, Y'"/>
</xsl:call-template>|

yields: ||

Your with-param element is not written correctly. It should look like this:

<xsl:call-template name="format-date">
    <xsl:with-param name="date" select="'2005-12-01'" />
</xsl:call-template>

Notice the select instead of value.

facepalm

I am new to XSLT (can you tell?!) and I make this same mistake at least 3 times a day working with Symphony, but I tell you I am still blind to it.

Needless to say this completely fixed my problem. Thank you very much @Nils! Sorry to waste your time... Hopefully this will be the straw that broke the camel's back and makes me stop doing this...

:: headdesk :: I missed that too.

You're welcome :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details