Created
January 20, 2017 09:37
-
-
Save MatthewBarker/25f21f70d5f98a71fa737d94010eec65 to your computer and use it in GitHub Desktop.
Parse RSS pubDate using moment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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