作者andreli (大学生)
看板PHP
标题Re: [请益] 请问关於时间的问题...
时间Thu May 11 17:46:36 2006
※ 引述《EAFV (EAFV)》之铭言:
: ※ 引述《suomax (shadow)》之铭言:
: : 大家好
: : 我有一个时间的字串 "YYYY-MM-DD HH:MM:SS" 是用当地时间储存的
: : 现在我希望能把它转换成 GMT 时间
: : 请问应该怎麽做呢?
: : 谢谢~
: 嗯...要作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
--
别那麽好奇,你按了我会知道
http://saygosh.com/me/ptt/?id=&user=andre
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.164.226.186