Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • chris 69 posts 92 karma points
    Aug 25, 2011 @ 21:43
    chris
    0

    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.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 25, 2011 @ 22:43
    Chriztian Steinmeier
    0

    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

  • chris 69 posts 92 karma points
    Aug 25, 2011 @ 22:52
    chris
    1

    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.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 25, 2011 @ 23:26
    Chriztian Steinmeier
    0

    Good thinking, Chris - clever :-)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft