Pergunta

I can't seem to get the correct Unix epoch time out of this PHP DateTime object.

$startingDateTime = "2005/08/15 1:52:01 am";

$foo = new DateTime($startingDateTime, new DateTimeZone("America/New_York"));

echo $foo->format('U');

which gives

1124085121

Which is Mon, 15 Aug 2005 00:52:01 GMT -500 (according to EPOCH CONVERTER) but that's incorrect by an hour.

It SHOULD be 1124088721 and spit back at me as Mon, 15 Aug 2005 01:52:01 GMT -500

Any help would be appreciated.

Foi útil?

Solução

This is likely a DST problem with epoch converter. I used another converter to UTC time and then to America/New_York. I got the right answer given timestamp=1124085121

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top