views:

108

answers:

1

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.

+1  A: 

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

dnagirl
I think you're right. The problem ended up being on the back end when I was trying to fetch out the data and redisplay it to the screen from the database. Was making a new DateTime object and passing it the UTC timestamp AND a timezone. The DateTime object with the data to be displayed was interpreting the UTC timestamp as though it had an offset when it didn't
Jazzepi