开发者

Parse RSS pubDate to Date object in JavaScript

开发者 https://www.devze.com 2022-12-18 18:30 出处:网络
How would I do this? Tu开发者_如何学编程e, 2 Feb 2010 19:34:21 Etc/GMTIt works right out of the box. The Date object in JavaScript can be set by passing a number of standard time formats. The format

How would I do this?

Tu开发者_如何学编程e, 2 Feb 2010 19:34:21 Etc/GMT


It works right out of the box. The Date object in JavaScript can be set by passing a number of standard time formats. The format used in RSS is one of these.

Example:

var pubDate = "Sun, 27 Mar 2011 20:17:21 +0100";
var date = new Date(pubDate);

var months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var string = date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear()

alert(string);
0

精彩评论

暂无评论...
验证码 换一张
取 消