Domanda

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.

È stato utile?

Soluzione

How about this?

echo date("c",'1338048000');

Altri suggerimenti

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.

echo date("c", "1338048000").'+08:00';
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top