※ 引述《andreli (大學生)》之銘言:
: ※ 引述《EAFV (EAFV)》之銘言:
: : 嗯...要作RSS用的嗎?
: : $date = date("Y-m-d H:i:s");
: : $time = mktime(
: : (int)substr($date,11,2),
: : (int)substr($date,14,2),
: : (int)substr($date,17,2),
: : (int)substr($date,5,2),
: : (int)substr($date,8,2),
: : (int)substr($date,0,4));
: : $times = sprintf("%s GMT",gmdate("M, d Y H:i:s",$time));
: : 這樣應該就可以了
: 如果是使用標準的儲存日期格式(其他樣子我沒用過,只試過date("Y-m-d H:i:s"))
: 可以試試下面那個函式,蠻方便取出timestamp的
: $time=strtotime($date)
: 剩下的就自己加加減減吧。
: 更詳細的用法請參照php.net
感謝兩位!最後我用了 strtotime(),因為字串格式是 ISO8601。
因為我的時間最後還是要輸出成字串,所以最後的結果是這樣:
$gmtTStr = gmstrftime( "%Y-%m-%d %H:%M:%S", strtotime($localTStr));
用 strtotime() 讀成 timestamp,然後 gmstrftime() 會用 GMT 輸出。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.215.199