PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Utsav Handa   Timezone Converter   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: Timezone Converter
Converts dates and times between time zones
Author: By
Last change:
Date: 15 years ago
Size: 1,572 bytes
 

Contents

Class file image Download
<?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";


?>