| | |
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 |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web webdesign websphere white xml youtube





