So I have a String which will be something like Wed, 08 May 2013 11:11:30 GMT
. (FYI, it is pulled from an XML RSS file) What I am trying to to is go from the above string to two variables, Wed, 08 May
and 11:11
. As far as I can tell, there are several things that need to be done here:
- Cut out the text before the 3rd space
- Cut out the text between the 4th space and the 2nd colon
- Save those two pieces of text as variables
Other than that, I am not sure what to do. Can anyone help? My code so far is as below:
$.ajax({
type: 'GET',
url: 'proxy.php',
data: {requrl: "http://feeds.bbci.co.uk/news/rss.xml"},
dataType: 'xml',
success: function (xml) {
$('#newsTimeline').empty();
$(xml).find("item").each(function () {
//for(var i = 0; i < $item.length && i < 5; i++){
var title = $(this).find("title").text();
var description = $(this).find("description").text();
var linkUrl = $(this).find("link_url").text();
var link = "<a href='" + linkUrl + "' target='_blank'>Read More<a>";
$('#feedContainer').append('
<li>\
<time class="cbp_tmtime" datetime="2013-04-10 18:30"><span>4/10/13</span> <span>18:30</span></time>\
<div class="cbp_tmicon cbp_tmicon-phone"></div>\
<div class="cbp_tmlabel">\
<h2>Ricebean black-eyed pea</h2>\
<p>Winter purslane courgette pumpkin quandong komatsuna fennel green bean cucumber watercress. Pea sprouts wattle seed rutabaga okra yarrow cress avocado grape radish bush tomato ricebean black-eyed pea maize eggplant. Cabbage lentil cucumber chickpea sorrel gram garbanzo plantain lotus root bok choy squash cress potato summer purslane salsify fennel horseradish dulse. Winter purslane garbanzo artichoke broccoli lentil corn okra silver beet celery quandong. Plantain salad beetroot bunya nuts black-eyed pea collard greens radish water spinach gourd chicory prairie turnip avocado sierra leone bologi.</p>\
</div>\
</li>\
');
//}
});
}
});
As you can see, I am already stripping out the title, description and read more text. The proxy.php file is just a file_get_contents request.
The solution to your problem is at: Parse RSS pubDate to Date object in JavaScript
In order to also get the hours: