PHP function for Time Zone conversion

I recently found that PHP doesn’t have an inbuilt function for conversion of time/date between multiple time zones and neither could I find a third-party function for the purpose. However, I did find the PEAR class which has inbuilt support for multiple time-zones but it cannot be used by “including” itself in the php page. PEAR class can be used only after installation, which may not be feasible in each and every case.
To avoid the hassles of installation I have written a set of 3 functions in PHP which wil allows you to -

  1. Convert GMT to local time zone
  2. Convert local time zone to GMT
  3. Convert between two different time zones.

Is this an advertisement or are you looking for a discussion on the topic?

Here’s how I would change the timezone:

// Create a datetime with time zone set to UTC
$dt = new DateTime("2010-03-24 12:34", new DateTimezone("UTC"));

// Change the time zone to LA
$dt->setTimezone(new DateTimezone("America/Los_Angeles"));

Which outputs:

string(31) "Wed, 24 Mar 2010 12:34:00 +0000"
string(31) "Wed, 24 Mar 2010 05:34:00 -0700"