We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40735
    • 119 Posts
    Hi!
    I'm consuming an RSS feed from our RAVE alert system in order to display these alerts on our website. I have set it up like so:

    Feed page:
    <?xml version="1.0" encoding="UTF-8"?>
    <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
        [[!getFeed? &url=`http://www.getrave.com/rss/tntech/channel3` &tpl=`raveRSS`]]
    </rss>


    raveRSS chunk:
    <item>
        <title>[[+title]]</title>
        <link>[[+link]]</link>
        <description>[[+description]]</description>
        <category>[[+category]]</category>
        <pubDate>[[+pubdate]]</pubDate>
        <guid>[[+guid]]</guid>
        <dc:date>[[+dc.date]]</dc:date>
        <date_timestamp>[[+date_timestamp]]</date_timestamp>
        <time_ago>[[+date_timestamp:date=`%d-%m-%Y`:ago]]</time_ago>
    </item>


    The trouble is that the "date" output filter is producing the wrong date. The timestamp is 1424065318 which converts to 02/16/2015 @ 5:41am (UTC) and is correct but the date that MODX is giving me is 15-02-2015, which the "ago" filter converts to "1 day, 7 hours ago" (at the time of this writing). I tried changing it to %c but that gave me Sun Feb 15 23:41:58 2015, which the "ago" filter converted to "7 hours ago." This is closer but it's still off by ~5 hours. I had this same trouble with some JavaScript and I discovered it was because I was using the Date object's "get*" functions instead of the "getUTC*" functions. I don't see any way to make such a change in MODX though.

    Help?
    Thanks! [ed. note: dwillis210 last edited this post 9 years, 2 months ago.]
    • Maybe you need to use a snippet, passing it the date_timestamp placehoder. Then you can do whatever you want to with the timestamp.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 40735
        • 119 Posts
        Yeah, I could work around it that way. But shouldn't the output filter work as expected? I think it has something to do with DST because it was working fine when I first coded it back in the summer.
          • 42046
          • 436 Posts
          I wonder if this could be the result of a timezone mismatch between php and mysql?
            • 3749
            • 24,544 Posts
            It might also be the server offset time.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 40735
              • 119 Posts
              The issue has mysteriously fixed itself. The next alert that went through and all the ones after that had the correct timestamp and time ago using the %c date pattern. I can't see anything different between the first one and the rest of them but I'm glad it's working. It makes me wonder if it will happen again sometime though.