Format pubdate from RSS feed
I have this RSS pubDate -- Tue, 27 Mar 2012 01:00:00 -0400 . How do I convert to ''EEE, MM-dd-yy". Here is my original script:
#set ($items = $_XPathTool.selectNodes($contentRoot, "/rss/channel/item"))
#foreach ($item in $items)
# set ( $pubDate = $_DateTool.toDate("EEE, MM-dd-yyyy",$item.getChild("pubDate").value ) )
$pubDate
#end
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Charlie Holder on 29 Mar, 2012 03:06 PM
Looks like you might just want to adjust the mask that's being used on the .toDate() method. What happens when you change that to be the format you listed?
3 Posted by pinaydiver on 29 Mar, 2012 03:14 PM
it does not return a value.
Support Staff 4 Posted by Charlie Holder on 29 Mar, 2012 03:24 PM
What does this do?
5 Posted by pinaydiver on 29 Mar, 2012 03:29 PM
It gives returns this value=> $newPubDate
Support Staff 6 Posted by Charlie Holder on 29 Mar, 2012 03:51 PM
I think there's an error with my code up there. Did you catch that when you tested? I'm missing a closing paren.
Syntax corrected:
7 Posted by pinaydiver on 29 Mar, 2012 05:20 PM
This returns --> $newPubDate .
Support Staff 8 Posted by Charlie Holder on 29 Mar, 2012 05:40 PM
It's probably a matter of matching the output from the RSS feed then. The .toDate mask that you're passing should match what's being returned from the pubDate node in the RSS feed.
Create a new mask that matches "Tue, 27 Mar 2012 01:00:00 -0400" using these patterns and see if that helps.
9 Posted by pinaydiver on 29 Mar, 2012 05:56 PM
Thanks Charlie. It is now working. I revised the script as follows:
Bradley Wagner closed this discussion on 29 Mar, 2012 10:06 PM.