News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Builder.com:
Get the correct time by converting between time zones with PHP and PEAR
October 10, 2006 @ 09:38:00

On the Builder.com website, there's a new tutorial demonstrating how to use the PEAR Date class to make switching between time zones a snap.

To be fair, PHP has built-in time zone functions to help with this, but these aren't particularly intuitive and require a fair amount of time to get used to. A quicker alternative is to use the PEAR Date class, which comes with built-in support for time zones and is, by far, the simplest way to perform these conversions.

This tutorial will teach you how to convert temporal values between time zones with the PEAR Date class. It assumes that you have a working Apache and PHP installation and that the PEAR Date class has been correctly installed.

They go with a few simple examples to introduce you to how things work:

  • just taking in and echoing back out the date
  • taking in the date and echoing it back out in a different format
  • making a simple time zone conversion
  • convert the timestamp to local time
  • finding the offset for the time stamp from GMT
  • adding and subtracting time stamps
all complete with the (simple) code to perform them all.

0 comments voice your opinion now!
pear date class time zone convert offset pear date class time zone convert offset


blog comments powered by Disqus

Similar Posts

Marco Tabini's Blog: Is PHP running out of itches to scratch?

DevShed: Building a Data Validation System with the Prototype Pattern with PHP 5

Jani Hartikainen's Blog: Base classes in OOP programming languages

Community News: Latest PEAR Releases for 03.26.2007

Pádraic Brady's Blog: PHP OpenID 2.0 library for PEAR Updates


Community Events





Don't see your event here?
Let us know!


tips zendserver list api release threedevsandamaybe interview bugfix code series symfony community development deployment introduction language laravel podcast conference framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework