PHP Classes

Timezone Converter: Converts dates and times between time zones

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 998 All time: 3,654 This week: 660Up
Version Licenses PHP version Categories
timezoneconverterapi 1.0GNU General Publi...4.0Localization, Time and Date
Description 

Author

This class can be used to convert dates and times between time zones.

It takes a given date and time in a given time zone and can convert the data and time to another of about 200 supported time zones.

Picture of Utsav Handa
Name: Utsav Handa <contact>
Classes: 3 packages by
Country: India India
Age: 40
All time rank: 54434 in India India
Week rank: 170 Up21 in India India Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php

/**
This class implements Timezone datetime conversion functionality.

There is a simple usage for converting specified datetime into specified timezone.

This class supports about 200 timezone conversion including some local timezone.
This class uses generic PHP functions for conversion.
**/


print "Simple Example ::";
/***************** Simple Example ********************/
/** convert local datetime to IST (Indian Standard Time) */
require_once('class-timezone-conversion.php'); /** Include class */
$tz = new TimezoneConversion(); /** Create TimezoneConversion Object */
$tz->setProperty('DateTime', 'now'); /** Set local 'DateTime' to convert */
$tz->setProperty('Timezone', 'IST'); /** Get IST */
print "\n IST ::" . $tz->convertDateTime();


print
"\n\n Advanced Example ::";
/***************** Advanced Example ********************/
/** Convert local 'DateTime' to ISt (Indian Standard Time) and then convert IST to PDT (Pacific Daylight Time) */
$tz = new TimezoneConversion(); /** Create TimezoneConversion Object */
$tz->setProperty('DateTime', 'now'); /** Set local 'DateTime' to convert */
$tz->setProperty('Timezone', 'IST'); /** Get IST */
$ist_datetime = $tz->convertDateTime();
print
"\n IST ::" . $ist_datetime;
/** IST => PDT */
$tz->setProperty('DateTime', $ist_datetime); /** Set IST to convert to PDT */
$tz->setProperty('Timezone', 'PDT'); /** Get PDT */
print "\n PDT ::" . $tz->convertDateTime()."\n";


?>


Details

/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -= imezone Conversion -= -= File: class-timezone-conversion.php -= -= Created by: Utsav Handa -= -= Email: handautsav [at] hotmail dot com -= -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ This class implements Timezone datetime conversion functionality. There is a simple usage for converting specified datetime into specified timezone. This class supports about 200 timezone conversion including some local timezone. This class uses generic PHP functions for conversion. Description:: --------------- This class provides a simple method to convert between time zones. It simply uses the built-in PHP function(s) which is available in PHP 4.x and higher. This class supports about 200 timezone conversion including some local timezone around the World. The TimezoneConversion rules on which this converter is based are to provide you with the most accurate time converter utility on the Net! Example : /** require_once('class-timezone-conversion.php'); $tz = new TimezoneConversion(); print "\n Local:: " .$tz->getLocalDateTime(); print "\n GMT ::" .$tz->convertDateTime(); $tz->setProperty('Timezone', 'IST'); print "\n IST ::" .$tz->convertDateTime(); **/ This class it's intended only for experimental/learning purposes. This class is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Utsav Handa - handautsav [at] hotmail dot com

  Files folder image Files (4)  
File Role Description
Plain text file class-timezone-conversion-php4.php Class This library provides generic timezone conversion functionlity (for PHP < 5.0)
Plain text file class-timezone-conversion.php Class This library provides generic timezone conversion functionlity in an uniform way.
Accessible without login Plain text file example.php Example Example Script
Accessible without login Plain text file ReadME.txt Doc. ReadMe Manual

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:998
This week:0
All time:3,654
This week:660Up
User Ratings User Comments (1)
 All time
Utility:62%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:68%StarStarStarStar
Examples:68%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2348