Php 如何将此特定日期和时间转换为其他格式?

Php 如何将此特定日期和时间转换为其他格式?,php,Php,我从facebook订阅源中得到了这个时间戳。我需要的是转换我如何转换以下日期和时间,并在结果中再添加1小时 2014-05-28T06:47:05+01:00 至28/05 08:47 多谢各位 // Convert to a DateTime object $dateTime = new DateTime('2014-05-28T06:47:05+01:00'); $dateTime->setTimezone(new DateTimeZone('UTC')); // Add an

我从facebook订阅源中得到了这个时间戳。我需要的是转换我如何转换以下日期和时间,并在结果中再添加1小时

2014-05-28T06:47:05+01:00
28/05 08:47

多谢各位

// Convert to a DateTime object
$dateTime = new DateTime('2014-05-28T06:47:05+01:00');
$dateTime->setTimezone(new DateTimeZone('UTC'));

// Add an hour (as you requested)
$dateTime->add(new DateInterval('PT1H'));

// Display formatted date/time
echo $dateTime->format('Y-m-d H:i:s');

或者您选择的时区

您可以使用
strotime
将时间转换为整数,然后使用
date
将其转换回所需格式的字符串。

可能不是完全重复的,但那里的答案几乎涵盖了相同的情况。您如何指示08:47的时区?看起来datetime字符串已经有时区偏移,因此将其转换为UTC可能会产生意外结果。@OscarM。-这正是我要求澄清的原因;虽然+01:00也可能是DST