将Twitter的日期格式转换为日期时间

时间:2012-10-18 20:11:23

标签: php date datetime twitter utc

Twitter的API以这种格式开出日期:

Thu, 18 Oct 2012 09:37:01 +0000

是否可以使用PHP将其转换为日期时间格式,用于我的数据库? E.g。

2012-10-18 09:37:01

2 个答案:

答案 0 :(得分:6)

date( 'Y-m-d H:i:s', strtotime("Thu, 18 Oct 2012 09:37:01 +0000") );

答案 1 :(得分:1)

使用格式为

的日期时间对象
$date = DateTime::createFromFormat('D, j M Y H:i:s +0000', 'Thu, 18 Oct 2012 09:37:01 +0000');
echo $date->format('Y-m-d H:i:s');