0

I am tring to make the google news sitemap by php script from mysql.(all the date save as timestamp in +08:00)

But how to converting date to YYYY-MM-DD hh:mm:ssTZD?

For example 1338048000 => 2012-05-26T09:00:00+08:00

echo date("Y-m-d T h:i:s",'1338048000').'+08:00';//2012-05-26 PDT 09:00:00+08:00 

Not the result what I need. And how to? Thanks.

John Conde
  • 217,595
  • 99
  • 455
  • 496
fish man
  • 2,666
  • 21
  • 54
  • 94

3 Answers3

1

I'd say:

gmdate('Y-m-d\TH:i:s\Z', '1338048000');

The T means something, and needs to be escaped. Or, since PHP5, the ISO8601 date format is natively supported with the c character.

Additionally, using gmdate instead of date removes the need to worry about timezones.

Pierre
  • 6,084
  • 5
  • 32
  • 52
1

How about this?

echo date("c",'1338048000');
ogur
  • 4,526
  • 2
  • 17
  • 17
0
echo date("c", "1338048000").'+08:00';
Jeroen
  • 13,056
  • 4
  • 42
  • 63