Page 1 of 3
Time not displaying properly with php 5.1.2
Posted: Thu Apr 26, 2007 7:21 am
by sarav_dude
Hello all, I am using php 5.1.2 and when i just
Code: Select all
echo "Time: ". date("h:i:s")."\n";
it does not display the correct time as my system on the localhost, and i have also check this with php4 , it is working fine in php4, please help thanks
Posted: Thu Apr 26, 2007 7:50 am
by louie35
try this:
Code: Select all
echo "Date/Time".date("Y-m-d H:i:s");
Posted: Thu Apr 26, 2007 7:55 am
by sarav_dude
Thanks for considering, i used the code you provided, it displays on localhost :
Date/Time2007-04-26 12:54:15
and my current system time is 6:25 pm, i cant able to figure out , the difference, please help
Posted: Thu Apr 26, 2007 7:57 am
by louie35
if is running on localhost then it has to be something else wrong there.
Posted: Thu Apr 26, 2007 8:01 am
by aaronhall
If you're using PHP5, post the results of this:
Code: Select all
<?php echo date_default_timezone_get(); ?>
Posted: Thu Apr 26, 2007 8:01 am
by sarav_dude
Thats what i am trying to figure out, with php 4 it is working fine, i am currently using php5.1.2 , may be some settings in the php.ini file or something ...
Posted: Thu Apr 26, 2007 8:05 am
by sarav_dude
aaronhall wrote:If you're using PHP5, post the results of this:
Code: Select all
<?php echo date_default_timezone_get(); ?>
it is : UTC
Posted: Thu Apr 26, 2007 8:07 am
by volka
And now please try
Code: Select all
echo phpversion(), "<br />\n";
echo php_uname(), "<br />\n";
echo "Time: ", time(), "<br />\n";
echo "Date/Time: ", date("Y-m-d H:i:s T O e");
on both systems, your server and localhost and post the output.
If it shows the dns name of your server and you don't want us to see it remove that part, it's irrelevant.
Posted: Thu Apr 26, 2007 8:13 am
by sarav_dude
volka wrote:And now please try
Code: Select all
echo phpversion(), "<br />\n";
echo php_uname(), "<br />\n";
echo "Time: ", time(), "<br />\n";
echo "Date/Time: ", date("Y-m-d H:i:s T O e");
on both systems, your server and localhost and post the output.
If it shows the dns name of your server and you don't want us to see it remove that part, it's irrelevant.
on localhost :
Code: Select all
5.1.2
Windows NT SARAV 5.1 build 2600
Time: 1177593063
Date/Time: 2007-04-26 13:11:03 UTC +0000 UTC
on server:
Code: Select all
5.1.6
Linux server (dnsname )ELsmp #1 SMP Fri Oct 6 06:21:39 CDT 2006 i686
Time: 1177593189
Date/Time: 2007-04-26 09:13:09 EDT -0400 America/New_York
Posted: Thu Apr 26, 2007 8:26 am
by aaronhall
Try adjusting the date.timezone directive in php.ini (
http://www.php.net/manual/en/ref.dateti ... e.timezone)
Posted: Thu Apr 26, 2007 8:30 am
by volka
Your server has another zoneinfo/timezone setting than localhost.
EDT -0400 America/New_York means, America/New_York currently is UTC -4 hours.
UTC=13:11:03 <-> EDT=09:13:09
When daylight saving is over America/New_York has UTC -5 hours (EST)
Posted: Thu Apr 26, 2007 8:42 am
by aaronhall
I think he was asking about a discrepancy between his system time and the time reported by PHP on that same system.
Re: Time not displaying properly with php 5.1.2
Posted: Thu Apr 26, 2007 8:43 am
by volka
If so I misunderstood
sarav_dude wrote:it does not display the correct time as my system on the localhost
Posted: Tue May 01, 2007 1:35 am
by sarav_dude
aaronhall wrote:I think he was asking about a discrepancy between his system time and the time reported by PHP on that same system.
Yes it is what i am trying to ask , the same thing i have checked on the php4, it shows the correct time, may be there is an bug in the version php5.1.2 for the server timings (the server is on the same system i.e., localhost), any way the solution to the problem is to manually calculate the time-difference and adds them to show the needed time. thanks all
Posted: Tue May 01, 2007 11:50 am
by volka
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