Apache time stamp incorrect

跟風遠走 提交于 2019-12-01 04:16:40

问题


I am using WAMP server running PHP. At a particular step I am trying to capture system time and add it to the database with the following query

$strSQLInsert = "UPDATE  track SET  State = 'Repeat' , DateTime = '" . date("m/d/Y h:i:s a") .  "',  where AccID like '". $values['SampleID'] ;

but the time stamp is way off than my system time. The date is okay. I googled and found out that I can update my .htaccess with this line

SetEnv TZ America/Los_Angles

But I couldn't find where htaccess is. How do I get the correct time stamp.


回答1:


Try to change the timezone in the php.ini configuration file, and then restart the apache service. You should have php.ini somewhere inside your WAMP installation folder.

EDIT: You might have the php.ini file inside the folder:

/wamp/bin/php/phpX.X.X

where phpX.X.X is your php version.

Look for the "date.timezone" line and change it to something like this:

date.timezone = "America/Los_Angeles"

You can find the supported timezones here: http://www.php.net/manual/en/timezones.php

More technical information is available here: http://php.net/manual/en/datetime.configuration.php

The .htaccess file has a local range, normally to the folder and sub-folders where the file is created. Changing the php.ini file makes the changes global to your PHP installation.




回答2:


In addition to editing the /wamp/bin/php/phpX.X.X/php.ini you would need to make the same changes on Apache side too. Which is on /wamp/bin/apache/ApacheX.X.X/bin/php.ini




回答3:


I'm using wampserver 3.0 and having the same issue even after changing date.timezone for both files:

  • \bin\php\php5.6.15\phpForApache.ini
  • \bin\php\php5.6.15\php.ini

After the changes the server was stopped/started, also tried using the restart button. Result are the following:

  • Date is ok (as before) but time is still off by exactly 50 minutes.
  • Apache access log shows correct time offset at +8 hours
  • Php error log shows correct time zone



来源:https://stackoverflow.com/questions/8596083/apache-time-stamp-incorrect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!