I’m using AJAX to pull in an RSS feed and show a list of items. However the date that comes back is super long and needs to be shorter.
e.g. Mon, 11 Jun 2012 17:53:35 PDT to become just 11 Jun 2012 17:53
Is it possible to do this with javascript?
The code looks like this currently:
for(var i = 0; i < feed.items.length && i < 5; i++) {
var item = feed.items[i];
html += '<li>'
+ item.updated;
html += ' | <span class="title">'
+ '<a href="'
+ item.link
+ '">'
+ item.title
+ '</a>'
+ '</span></li>';
}
So I need to do something to that item.updated object.
I’ve done a quick search on parsing dates, but not found anything I can make use of.
You can use this RegEx:
Or even simpler:
Even more simpler:
But if you care about timezones, i.e. want to display the client’s timezone instead, you can do this: