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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information 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
Gertone (Geert Bormans)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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KBueschingAuthor Commented:
Understood - and I appreciate the help. Too many other things due before I can call it a day. Thanks again.
0
Gertone (Geert Bormans)Information ArchitectCommented:
welcome, good luck
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.