Using DateTime in PHP, generating bad unix epoch time from $foo->format('U')
Posted
by Jazzepi
on Stack Overflow
See other posts from Stack Overflow
or by Jazzepi
Published on 2010-04-21T16:40:11Z
Indexed on
2010/04/21
16:43 UTC
Read the original article
Hit count: 282
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 http://www.epochconverter.com/) 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.
© Stack Overflow or respective owner