I’m keeping my homepage in a SVN repository; I’m using the $Date$ variable to automatically track the last modification date (though it will also change on minor modifications).

For the HTML “Date” meta tag, the W3C recommends using ISO8601 date format. This is the (non-XSLT-2, so no regexp) hack I use for conversion:

<xsl:value-of select="concat(substring($string,8,4),'-',substring($string,13,2),'-',substring($string,16,2),'T',substring($string,19,8),substring($string,28,5))" />

Did I mention I hate XSLT? It’s lacking so many standard functions, like date-time processing, regular expressions, exceptions, … - granted, a lot of stuff was added for XSLT2, but it still sucks badly. Especially the syntax.

Here’s how to format the date according to RFC 2616, as used in the last-modified meta tag and HTTP/NNTP/SMTP headers:

<xsl:variable name="day" select="concat(substring($string,8,4),'-',substring($string,13,2),'-',substring($string,16,2))" />
<xsl:variable name="time" select="substring($string,19,8)" />
<xsl:variable name="timezone" select="substring($string,28,5)" />
<xsl:value-of select="date:day-abbreviation($day)" />
<xsl:text>, </xsl:text>
<xsl:value-of select="date:day-in-month($day)" />
<xsl:text> </xsl:text>
<xsl:value-of select="date:month-abbreviation($day)" />
<xsl:text> </xsl:text>
<xsl:value-of select="date:year($day)" />
<xsl:text> </xsl:text>
<xsl:value-of select="date:time($time)" />
<xsl:text> </xsl:text>
<xsl:value-of select="$timezone" />

Note that this does not include any error handling and is not very robust. You also need an XSLT processor with some of the http://exslt.org/dates-and-times extensions such as xsltproc. (Which unfortunately doesn’t do XSLT2 yet and doesn’t have a regexp extension).

[Update: Joel Wreed pointed me to his libxslt plugins, a regexp and a exsl.org/dates-and-times plugin. These would help a lot, though IIRC the date-parse exsl.org spec doesn’t support the date format I’d need. (So I can’t just say date-format(date-parse(…),…)). Also he said that they basically are unmaintained right now. It would be nice if they could be merged into libxslt, though…]