Skip to content

Instantly share code, notes, and snippets.

@MatthewBarker
Created January 20, 2017 09:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewBarker/25f21f70d5f98a71fa737d94010eec65 to your computer and use it in GitHub Desktop.
Save MatthewBarker/25f21f70d5f98a71fa737d94010eec65 to your computer and use it in GitHub Desktop.
Parse RSS pubDate using moment.js
// RSS feeds are supposed to have a standardised date format, as shown in the RSS 2.0 specification:
// All date-times in RSS conform to the Date and Time Specification of RFC 822,
// with the exception that the year may be expressed with two characters or four characters (four preferred).
// Example: Sat, 07 Sep 2002 0:00:01 GMT
var formats = ['ddd, DD MMM YYYY HH:mm:ss ZZ', 'ddd, DD MMM YY HH:mm:ss ZZ'];
var pubDate = moment(item.querySelector('pubDate').textContent, formats);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment