Tuesday, July 24, 2012

JavaScript: Parse a long date into a shorter one



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.






Rating: 3 out of 5 based on 3 ratings



The post JavaScript: Parse a long date into a shorter one appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-parse-a-long-date-into-a-shorter-one.html

No comments:

Post a Comment