Search

I have an RSS feed that contains a date in the following format

Thu, 06 Sep 2012 05:12:12 +0100

I need to get this date into the following format

2012-09-06T06:12:12

Notice that I've added the +0100 to the hour.

Has anyone got a utility that can do what I need?

Sadly all the utilities listed on the site require the date to be provided as the latter format, not the former.

Thanks anyway Nick.

Not really but thanks.

I've tried the following template, but none of the variables are being populated:

<xsl:template name="rssdate-to-isodate">

    <xsl:param name="rssdate" value="Thu, 06 Sep 2012 05:12:12 +0100"/>

    <xsl:variable name="year" select="substring($rssdate, 13, 16)"/>
    <xsl:variable name="month">
        <xsl:choose>
            <xsl:when test="substring($rssdate, 9, 11) = 'Jan'">
                <xsl:text>01</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Feb'">
                <xsl:text>02</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Mar'">
                <xsl:text>03</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Apr'">
                <xsl:text>04</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'May'">
                <xsl:text>05</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Jun'">
                <xsl:text>06</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Jul'">
                <xsl:text>07</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Aug'">
                <xsl:text>08</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Sep'">
                <xsl:text>09</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Oct'">
                <xsl:text>10</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Nov'">
                <xsl:text>11</xsl:text>
            </xsl:when>
            <xsl:when test="substring($rssdate, 9, 11) = 'Dec'">
                <xsl:text>12</xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="day" select="substring($rssdate, 6, 7)"/>

    <xsl:variable name="hours">
        <xsl:choose>
            <xsl:when test="substring($rssdate, 27, 27) = '-'">
                <xsl:value-of select="substring($rssdate, 18, 19) - substring($rssdate, 28, 29)"/>
            </xsl:when>
            <xsl:when test="substring($rssdate, 27, 27) = '+'">
                <xsl:value-of select="substring($rssdate, 18, 19) + substring($rssdate, 28, 29)"/>
            </xsl:when>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="minutes" select="substring($rssdate, 21, 22)"/>
    <xsl:variable name="seconds" select="substring($rssdate, 24, 25)"/>

    <xsl:value-of select="concat($year,'-',$month,'-',$day,'T',$hours,':',$minutes,':',$seconds)"/>

</xsl:template>

Has anyone any idea of why?

Sadly all the utilities listed on the site require the date to be provided as the latter format, not the former

I'm pretty sure the purpose of the Twitter Date Formatter utility is to parse a Twitter date Thu, 06 Sep 2012 05:12:12 +0100 like you described.

It can't output a date time formatted in ISO like I need though.

This is probably a good time to use the EXSLT Function Manager extension. You can write a simple PHP function to read the Twitter date, run through strtotime and format as you wish.

(If you need an example of how to get it working, grab me on Skype, I can direct you to a repo!)

I've fixed it by correcting my template above.

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