xsl datetime format with correct Timezone

Posted on 2005-05-03
Last Modified: 2008-01-09
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">
    <copyright>Copyright MHA</copyright>
    <generator>Webservice og DB</generator>
    <lastBuildDate>Tue, 03 May 2005 15:22:43 GMT</lastBuildDate>
      <pubDate>Sun, 24 Apr 2005 22:00:00 GMT</pubDate>
My rssfeed.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:template match="/">
  <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>        
      <xsl:for-each select="rss/channel/item">
      <xsl:variable name="articleid"><xsl:value-of select="link"/></xsl:variable>
      <a href="{$articleid}"><xsl:value-of select="title"/></a>
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!
Question by:michaenh
    LVL 19

    Accepted Solution

    in standard XSLT 1.0 you can't work with date formats.
    But many popular XSLT processors support extensions and that extensions have some functions which support manipualtion with dates. check
    Which XSLT processor do you use?

    Author Comment

    I use standard XSLT 1.0.
    So it is not possible? .. hm.. well I will check out with

    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.

    I'll be back.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now