-2

I got this timestamp from the facebook feed. What I need is to convert iHow can I convert the following date & time and add another 1 hour to the result?

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

to 28/05 08:47 ?

Thank you

EnexoOnoma
  • 8,454
  • 18
  • 94
  • 179

2 Answers2

2
// 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');

or your timezone of choice

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • It looks like the datetime string already has a timezone offset, so convertng it to UTC may have unintended results. – Oscar M. May 28 '14 at 13:43
  • @OscarM. - which is precisely why I asked for any clarification; though the +01:00 could also be DST – Mark Baker May 28 '14 at 13:44
0

You use strtotime to convert the time to an integer, then use date to convert it back to a string in the format you'd like.

Styphon
  • 10,304
  • 9
  • 52
  • 86