Remove Time from pubDate value

OK - last one (I hope) I need to remove the "time" from the pubDate

<xsl:value-of select="pubDate"/>

To display just the date and not the time

Here's what I have now - Thu, 15 Apr 2010 13:05:20 GMT

Even better if I could make the date more reader-friendly as 4/15/2010
KBueschingAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
you could have figured that out yourself, if it were urgent :)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:call-template name="formatDate">
            <xsl:with-param name="date" select="pubDate"></xsl:with-param>
        </xsl:call-template>
    </xsl:template>
    <xsl:template  name="formatDate">
        <xsl:param name="date"/>
        <xsl:variable name="map" select="'#Jan@01#Feb@02#Mar@03#Apr@04#May@05#Jun@06#Jul@07#Aug@08#Sep@09#Oct@10#Nov@11#Dec@12'"></xsl:variable>
        <xsl:variable name="day-stripped" select="normalize-space(substring-after($date, ','))"></xsl:variable>
        <xsl:variable name="day" select="substring-before($day-stripped, ' ')"/>
        <xsl:variable name="date-remainder" select="substring-after($day-stripped, ' ')"></xsl:variable>
        <xsl:variable name="month" select="substring-before($date-remainder, ' ')"></xsl:variable>
        <xsl:variable name="year" select="substring-before(substring-after($date-remainder, ' '), ' ')"></xsl:variable>
        <xsl:value-of select="substring-before(substring-after($map, concat('#', $month, '@')), '#')"/>
        <xsl:text>/</xsl:text>
        <xsl:value-of select="$day"/>
        <xsl:text>/</xsl:text>
        <xsl:value-of select="$year"/>
     </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
Geert BormansInformation ArchitectCommented:
given this XML

<pubDate>Thu, 15 Apr 2010 13:05:20 GMT</pubDate>

This XSLT will give you what you need, just call the template in your real XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:call-template name="formatDate">
            <xsl:with-param name="date" select="pubDate"></xsl:with-param>
        </xsl:call-template>
    </xsl:template>
    <xsl:template  name="formatDate">
        <xsl:param name="date"/>
        <xsl:variable name="map" select="'#Jan@01#Feb@02#Mar@03#Apr@04#May@05#Jun@06#Jul@07#Aug@08#Sep@09#Oct@10#Nov@11#Dec@12'"></xsl:variable>
        <xsl:variable name="day-stripped" select="normalize-space(substring-after($date, ','))"></xsl:variable>
        <xsl:variable name="day" select="substring-before($day-stripped, ' ')"/>
        <xsl:variable name="date-remainder" select="substring-after($day-stripped, ' ')"></xsl:variable>
        <xsl:variable name="month" select="substring-before($date-remainder, ' ')"></xsl:variable>
        <xsl:variable name="year" select="substring-before(substring-after($date-remainder, ' '), ' ')"></xsl:variable>
        <xsl:value-of select="$day"/>
        <xsl:text>/</xsl:text>
        <xsl:value-of select="substring-before(substring-after($map, concat('#', $month, '@')), '#')"/>
        <xsl:text>/</xsl:text>
        <xsl:value-of select="$year"/>
     </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
KBueschingAuthor Commented:
Close - but I need month and date reversed to mm/dd/yyyy from the example above.
0
 
KBueschingAuthor Commented:
Understood - and I appreciate the help. Too many other things due before I can call it a day. Thanks again.
0
 
Geert BormansInformation ArchitectCommented:
welcome, good luck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.