xsl datetime format with correct Timezone

Hi.
I am working with rss newsfeed and my xml data is something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type='text/xsl' href='rssfeed.xsl'?>
<rss version="2.0">
  <channel>
    <title><![CDATA[News]]></title>
    <link>http://localhost</link>
    <description><![CDATA[blabla...]]></description>
    <language>no</language>
    <copyright>Copyright MHA</copyright>
    <managingEditor>webmaster</managingEditor>
    <generator>Webservice og DB</generator>
    <lastBuildDate>Tue, 03 May 2005 15:22:43 GMT</lastBuildDate>
    <item>
      <title><![CDATA[Test]]></title>
      <description><![CDATA[test]]></description>
      <pubDate>Sun, 24 Apr 2005 22:00:00 GMT</pubDate>
      <link>http://localhost?ItemID=1925</link>
      <guid>http://localhost?ItemID=1925</guid>
      <author>webmaster</author>
    </item>
  </channel>
</rss>
----------------------------------------------------------------------
My rssfeed.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
  <h2>My rss</h2>
    <table style="TABLE-LAYOUT: fixed" cellSpacing="0" cellPadding="0" width="100%" border="0" heihjt="100%">
      <tr bgcolor="#9acd32">
        <th align="left">News</th>        
      </tr>
      <xsl:for-each select="rss/channel/item">
      <tr>
       <td>
      <xsl:variable name="articleid"><xsl:value-of select="link"/></xsl:variable>
      <a href="{$articleid}"><xsl:value-of select="title"/></a>
       </td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------------------
My question is how can I transform date and time format like this DD.MM.YYYY HH:mm:ss with a Norwegian Timezone(GMT+1) from the xml pubDate node.

Many thanks in advance!
Cheers,
MHA
michaenhAsked:
Who is Participating?
 
ramazanyichConnect With a Mentor Commented:
in standard XSLT 1.0 you can't work with date formats.
But many popular XSLT processors support exslt.com extensions and that extensions have some functions which support manipualtion with dates. check http://exslt.org/date/index.html 
Which XSLT processor do you use?
0
 
michaenhAuthor Commented:
Hi.
I use standard XSLT 1.0.
So it is not possible? .. hm.. well I will check out with http://exslt.org/date/index.html.

Added this to the .xsl file:
<xsl:variable name="day" select="substring-before(substring-after($date, ' '), ' ')"/>
<xsl:variable name="monthName" select="substring-before(substring-after(substring-after($date, ' '), ' '), ' ')"/>
<xsl:variable name="month" select="substring(substring-after('Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12', $monthName), 1, 2)"/>
<xsl:variable name="year" select="substring-before(substring-after(substring-after(substring-after($date, ' '), ' '), ' '), ' ')"/>
<xsl:variable name="Time" select="substring-before(substring-after(substring-after(substring-after(substring-after($date,' '),' '),' '),' '),' ')"/>
<xsl:value-of select="concat($day,'.',$month, '.',$year,' ',$Time)"/>

 I will get:
24.04.2005 22:00:00, but it s not the correct Timezone.

Thanks,
I'll be back.

Cheers,
MHA
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.