PHP date_create, converting UTC time to another time zone using time zone paragraph shortening

$placename=timezone_name_from_abbr("", $timezone * 3600, false);
                        $date = date_create($list['stamp'], timezone_open($placename));
                        $datetimezone=new DateTimeZone('Europe/London');
                        $dateTime = new DateTime($list['stamp'],$datetimezone); 
                        $dateTime->setTimeZone(new DateTimeZone($placename)); 

change

I tried the following code suggested as an answer, and it produced a time that was 2 hours less than it should have been. I checked my db and the time in DB is GMT. so the problem is to convert it from GMT using conversion

$timezone=-4

the user code answers, below it gives a time equal to two hours. converts from GMT to America / New _York, but it's two hours slower. I checked the placename variable to make sure it is America / New_York. what could be the reason for this?

$placename=timezone_name_from_abbr("", $timezone * 3600, true);
$dateTime = new DateTime($list['stamp']); 
$dateTime->setTimeZone(new DateTimeZone($placename)); 
echo $dateTime->format('F d g:i a'); 

original question

, America/New_York, UTC, , , ? db 2012-05-13 07:30:47

$placename=timezone_name_from_abbr("", $timezone * 3600, true);
$date = date_create($list['stamp'], timezone_open($placename));
echo date_format($date, 'F d g:i a');
+3
1
$dateTime = new DateTime($date,new DateTimeZone('Europe/London')); 
$dateTime->setTimeZone(new DateTimeZone('America/New_York')); 
echo $dateTime->format('F d g:i a'); 

, DateTime, , , , , , .

.

, ( ) , , PHP America New_York, , , .

//, , - :

Notice: Use of undefined constant America - assumed 'America' in line 3;

, , ( ), . PHP , , . , PHP, .

, , :)

( ), , ( ), , GMT GMT , .

, : :

$timezone , $time UNIX (, @946684800), (, 2010-01-28T15: 00: 00 + 02: 00).

+6

All Articles