Page 2 of 3
Posted: Wed May 02, 2007 1:21 am
by sarav_dude
volka wrote:I stand corrected.
You should do that instead of fiddeling with the timestamp.
Code: Select all
<?php echo get_cfg_var('cfg_file_path'); ?>
tells you which php.ini you have to change.
Don't forget to restart the webserver after changing the php.ini
hi , it just echos : the path of the php.ini file, it shows : D:/windows/php.ini
php bug
Posted: Wed May 02, 2007 1:31 am
by sarav_dude
Posted: Wed May 02, 2007 2:02 am
by volka
Just because someone cries bug it's not necessarily a bug
sarav_dude wrote:hi , it just echos : the path of the php.ini file, it shows : D:/windows/php.ini
As stated that's the php.ini you have to change.
I found the solution my problem
Posted: Wed May 02, 2007 2:08 am
by sarav_dude
I found the solution my problem, just setting the timezone to
Code: Select all
date_default_timezone_set('Indian/Cocos');
and subtracting one hour from that to display the correct time .
Posted: Wed May 02, 2007 2:12 am
by volka
If you write the timezone to the php.ini as described in
http://www.php.net/manual/en/ref.dateti ... e.timezone you don't have to call date_default_timezone_set() in each and every script.
If you still need to add an extra hour it's either the wrong timezone or the zoneinfo of your os needs an update.
Posted: Wed May 02, 2007 2:20 am
by sarav_dude
Yes you are right , may be some kind of update needed to my os as well as php, also i have checked the link given by you , it is good, but i was unable to find the settings mention on that page in my php.ini file , may be php needs an update, all the following settings are not present in my php.ini.
Code: Select all
date.default_latitude
date.default_longitude
date.sunrise_zenith
date.sunset_zenith
date.timezone
Posted: Wed May 02, 2007 2:28 am
by volka
Add them as you need them. If a parameter is missing from php.ini its default value is used
date.timezone was introduced in php 5.1.0, just add the line
date.timezone = 'Indian/Cocos' to D:/windows/php.ini, then restart the webserver.
When I run
Code: Select all
<?php
$timestamp = time();
echo "<pre>\n";
echo 'timestamp: ', $timestamp, "\n";
foreach( array('UTC', 'Europe/Berlin', 'Indian/Cocos') as $tz ) {
date_default_timezone_set($tz) or die('date_default_timezone_set('.$tz.') failed');
echo date("H:i:s T = \U\T\CO", $timestamp), "\n";
}
echo "\n</pre>";
?>
it prints
timestamp: 1178090884
07:28:04 UTC = UTC+0000
09:28:04 CEST = UTC+0200
13:58:04 CCT = UTC+0630
is it about 2pm where you're living?
Posted: Wed May 02, 2007 2:35 am
by sarav_dude
ok i will add and check what it displays, also it is 1:05 pm as per indian timings.
Posted: Wed May 02, 2007 2:45 am
by volka
Posted: Wed May 02, 2007 2:47 am
by sarav_dude
yes , i have just set
Code: Select all
ini_set("date.timezone","Indian/Cocos");
, and it is working fine now, thanks
Posted: Wed May 02, 2007 2:48 am
by volka
No need for ini_set, just put in in the php.ini. Otherwise you have to call ini_set() in each and every script just like with date_default_timezone_set()
Posted: Wed May 02, 2007 2:54 am
by sarav_dude
no sir , i live in india and as i mentioned before there is one hour difference with the setting "Indian/Cocos", so i subtract one hour to display the correct time.
yes i have put the settings in the php.ini file in my local system, but for my online site i have to use ini_set because i guess hosting server which is in USA wont allow to change their ini settings ...
Posted: Wed May 02, 2007 3:12 am
by volka
I probably misunderstood
sarav_dude wrote:yes , i have just set
Code: Select all
ini_set("date.timezone","Indian/Cocos");
, and it is working fine now, thanks
Let me ask you again: Do you live on
Cocos (Keeling) Islands?
Do you want the time settings for
Cocos (Keeling) Islands?
Cocos (Keeling) Islands is in the timezone UTC+06:30
UTC currently is 08:12:01 <-> it's 14:42:01 on
Cocos (Keeling) Islands
Posted: Wed May 02, 2007 3:19 am
by sarav_dude
sorry i forget to mentioned that i have search for timezone for the indian timings but i did not found that , so i used the one "indian/cocos" as it is closer to the indian timings what i needed , the "indian/cocos" timings are 2:49 pm and indian timings are 1:49 pm , so i subtract one hour from it to display the correct timings
Posted: Wed May 02, 2007 3:50 am
by volka
Asia/Calcutta and Asia/Colombo might be suitable, both have an offset of 19800 (seconds=5,5hours) and no daylight saving time.
Code: Select all
<?php
$timestamp = time();
echo "<pre>\n";
echo 'timestamp: ', $timestamp, "\n";
$zones = array(
'Asia/Calcutta',
'Asia/Colombo'
);
foreach( $zones as $tz ) {
date_default_timezone_set($tz) or die('date_default_timezone_set('.$tz.') failed');
echo date("H:i:s T = \U\T\CO", $timestamp), "\n";
}
echo "\n</pre>";
?>
timestamp: 1178095755
14:19:15 IST = UTC+0530
14:19:15 IST = UTC+0530