Professional Web Development Forums: change timezones in php

Jump to content

change timezones in php Bookmark

User is offline gilbertsavier 

  • Member
  • Group: Members
  • Posts: 18
  • Joined: 26-June 09
  • Current Mood: Current Mood: None Chosen

Find Posts Tutorial info

  • Added on: 12 August 2009 - 09:07 AM
  • Views: 562
Hi,
PHP scripting language have an built in function to change between the timezones , you will need the PEAR package . In the following example show you how to convert from GMT system format to IST Format .

// include class
include ("Date.php");

// initialize object
$d = new Date("2008-10-03 16:23:48");

// set server time zone
$d->setTZByID("GMT");

// print server time
echo "Local time is " . $d->format("%A, %d %B %Y %T") . "\n";

// convert to IST
$d->convertTZByID("PST");

// output converted date/time
echo "Destination time is " . $d->format("%A, %d %B %Y %T");

?>
0

Share:

Powered by (IM) Tutorials 1.1.0 © 2010, by Michael McCune

Enter your sign in name and password


Sign in options
  Or sign in with these services