Results 1 to 2 of 2
Mar 24, 2010, 04:14 #1
- Join Date
- Feb 2010
- 0 Post(s)
- 0 Thread(s)
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.
Last edited by DaveMaxwell; Mar 24, 2010 at 08:06. Reason: removed link
Mar 24, 2010, 06:57 #2
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
string(31) "Wed, 24 Mar 2010 12:34:00 +0000" string(31) "Wed, 24 Mar 2010 05:34:00 -0700"Salathe
Software Developer and PHP Manual Author.