解析rss订阅内容时候,发现pubDate是格林威治时间格式,在手册上找到这个函数,收藏
gmstrtotime($sgm) {
$months = array(
'Jan'=>1,
'Feb'=>2,
'Mar'=>3,
'Apr'=>4,
'May'=>5,
'Jun'=>6,
'Jul'=>7,
'Aug'=>8,
'Sep'=>9,
'Oct'=>10,
'Nov'=>11,
'Dec'=>12
);
list($D, $d, $M, $Y, $H, $i, $s) = sscanf($sgm, "%3s, %2d %3s %4d %2d:%2d:%2d");
return gmmktime($H, $i, $s, $months[$M], $d, $Y)-28800;#减去8小时时差
}