如何转换yyyy-MM-ddTHH:mm:ssZ到yyyy-MM-dd HH:mm:ss?

Paypal returns a timestamp of the following format:

yyyy-MM-ddTHH:mm:ssZ

And I don't quite know what to do with it...

How can I convert it to yyyy-MM-dd HH:mm:ss using my local timezone in php?

I'm tempted to preg_replace the mysterious letters, but something tells me there must a better way. There also appears to be 8 hours difference to my zone which I'm not sure how to substract.

Use DateTime class to do your magic.

$date = new DateTime('2012-09-09T21:24:34Z');
$date->format('Y-m-d'); # read format from date() function

You can use strtotime() to get a UNIX timestamp. From there you can do whatever you need: DateTime object, date(), etc.

Example with date():

echo date('r', strtotime('2012-09-10T10:00:00Z'));