| | |
change timezones in php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 6
Reputation:
Solved Threads: 0
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 .
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 .
php Syntax (Toggle Plain Text)
<?php // 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"); ?>
Last edited by peter_budo; Aug 14th, 2009 at 1:08 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Thanks & regards
Lokananth
[url "http://www.mioot.com"]Live Chat Software[/url] By miOOt
Lokananth
[url "http://www.mioot.com"]Live Chat Software[/url] By miOOt
sorry i am not sure about the code (pear package for date)
but i used to change the timezone as following
Just give it a try
but i used to change the timezone as following
php Syntax (Toggle Plain Text)
<?Php if(function_exists('date_default_timezone_set')){ date_default_timezone_set("Asia/Calcutta"); } else{ putenv("TZ=Asia/Calcutta"); } $date = date('l jS \of F Y h:i:s:c A'); ?>
Just give it a try
![]() |
Similar Threads
- PHP URL variables and if statement (PHP)
- Basic PHP Includes (PHP)
- Need help with changing the index.php file (Existing Scripts)
- Trying to get PHP to send smtp through sendmail 8 (PHP)
- Using PHP to connect to remote MSSQL database (PHP)
- mysql errors, from submit.php and index.php (PHP)
- need help in installing gd library with php 4.3.10 (PHP)
- Can a PHP website be edited by myself? (PHP)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search secure server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





