2

I'm having an issue when running a script in a browser versus the command line. The script echo's the date 1/20/2012 when running within the browser, however when running within the command prompt it echo's tommorows date 1/21/2012. I have set my timezone to the

date.timezone = America/New_York

I'm running this script in the command line:

"c:\wamp\bin\php\php5.3.4\php.exe" -f "c:\wamp\www\site.com\cron.php"

Any ideas on why I'm getting two different dates from the same script?

3
  • This is just a guess, but it's possible PHP's CLI SAPI is accessing the system clock to determine the time while the WAMP version is using your windows time settings? Not really sure here. WAMP/windows can get funky sometimes with PHP. Does the same thing occur if you set the timezone at runtime with date_default_timezone_set(); ??? Commented Jan 21, 2012 at 2:17
  • 2
    I think I figured this out, I'm surprised more people havn't run into this type of issue. WAMP has it's own PHP.ini file that resides within the Apache bin DIR. The command shell default PHP.ini used by PHP.exe is however in the same directory as..PHP.exe. Stupid WAMP! Commented Jan 21, 2012 at 2:31
  • Also, often times systems will provide 2 php.ini files, one for the command line, and another for the Web server. Commented Feb 1, 2012 at 3:19

2 Answers 2

1

check your Apache and command line have same PHP. and both using the same php.ini file.

Sign up to request clarification or add additional context in comments.

Comments

0

php-cli, php-cgi, & php-fpm all use different php.ini files by default.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.