I'm using XSLT to pull rss feed from other site to put it on my home page. The time on the publish date is according to the source. If I view this in the browser, it matches my time. So the browser is doing the conversion.
Is there xslt code somewhere that has such conversion? It would be useful to see the pubDate in the viewer's local time than the origin's publish date.
I'd suggest you do that with some client-side JavaScript, since the XSLT will only have access to the TimeZone on the server (unless you grab the browser's timezone on a previous request and store it in a cookie/localStorage etc.)
There are a set of DateTime extensions that may help you (e.g. FormatDateTime()). Crucial part is to know which timezone the RSS dates are in, then write them to the browser as UTC - and have the browser display the date in the local timezone.
RSS feed date/time conversion
I'm using XSLT to pull rss feed from other site to put it on my home page. The time on the publish date is according to the source. If I view this in the browser, it matches my time. So the browser is doing the conversion.
Is there xslt code somewhere that has such conversion? It would be useful to see the pubDate in the viewer's local time than the origin's publish date.
Hi chris,
I'd suggest you do that with some client-side JavaScript, since the XSLT will only have access to the TimeZone on the server (unless you grab the browser's timezone on a previous request and store it in a cookie/localStorage etc.)
There are a set of DateTime extensions that may help you (e.g. FormatDateTime()). Crucial part is to know which timezone the RSS dates are in, then write them to the browser as UTC - and have the browser display the date in the local timezone.
/Chriztian
Hi,
I figured it out. I assigned a parameter for the xslt macro.
<xsl:variablename="clock"select="/macro/clock" />
then I pull the time zone offset (-8 for PST), then use the dateAdd and later formatted into universal. This seems to be working fine.
<xsl:value-ofselect="umbraco.library:FormatDateTime(umbraco.library:DateAdd(pubDate, 'h', $clock), 'U' )" />
This seems to be working fine, except some feed, like the department of defense pic of the day, gives xslt parsing error.
Good thinking, Chris - clever :-)
/Chriztian
is working on a reply...