有没有人能把RSS转换成unix时间戳的函数?我试着使用了strtotime()的javascript版本,但它从未正确工作过。
发布于 2011-06-02 16:19:13
var pubDate = "Sun, 27 Mar 2011 20:17:21 +0100";
var date = new Date(pubDate);
var timestamp = Math.round(date.getTime()/1000);
alert(timestamp);http://jsfiddle.net/VDwVB/1/
发布于 2011-06-02 16:27:42
使用Date.parse可以更轻松地完成以下操作:
var pubDate = "Sun, 27 Mar 2011 20:17:21 +0100";
alert(Math.round(Date.parse(pubDate)/1000));发布于 2014-06-18 19:46:27
我认为获取unix时间戳的最简单方法(这是从1970年1月1日开始的以秒为单位的时间),如下所示:
var myDate = new Date("Sun, 27 Mar 2011 20:17:21 +0100");
console.log(+myDate); // +myDateObject give you the unix from that date
console.log(+myDate + 60); // if you want to add seconds for example, you just sum the seconds that you want to add, since myDate is the time in secondshttps://stackoverflow.com/questions/6212049
复制相似问题