Help with converting time zone using Pear Date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tayabi
Forum Newbie
Posts: 1
Joined: Wed Jun 04, 2008 3:37 pm

Help with converting time zone using Pear Date

Post by tayabi »

Hello, I'm trying to do what should be a very simple Time Zone conversion using Pear's Date package. The code I'm using is straight from the Pear docs but it's not quite working for me and I'm hoping someone could have a look and tell me where I'm going wrong please

Code: Select all

$now = date Date();
echo $now->getDate(); // 2008-06-04 15:26:00
 
$timezone = new Date_TimeZone('PST');
$now->convertTZ($timezone);
echo $now->getDate(); // 2008-06-04 07:26:00, should be 2008-06-04 13:26:00
As you can see, it's able to get the correct time from the server, but then when it converts it's behind by 6 hours. Any ideas what might be happening?

Thanks kindly
Post Reply