Changing PHP timezone not working
Posted: Tue Nov 15, 2022 12:40 am
I just discovered that my PHP CLI timezone on my localhost MAMP is set to Europe/Berlin...
When I run `die(phpinfo());` in my .php script through CLI, it shows this in the output:
date
Default timezone => Europe/Berlin
date.timezone => Europe/Berlin => Europe/Berlin
When I run `phpinfo()` through the normal web server, it shows correctly:
date
Default timezone America/Denver
Directive Local Value Master Value
date.timezone America/Denver America/Denver
When I look up how to change it for CLI, I find this page:
https://documentation.mamp.info/en/MAMP ... .ini-file/
When I click into MAMP > File > Open Template > PHP (php.ini) > PHP [the version I'm using], it opens `php[version].ini`, and under `[Date]` shows `date.timezone = MAMP_timezone_MAMP`. When I comment that line out and make a new one as `date.timezone = America/Denver` then restart MAMP, nothing changes in CLI or Web... apparently the instructions are wrong or incomplete.
CLI phpinfo says `Loaded Configuration File => /Applications/MAMP/bin/php/php[version]/conf/php.ini`.
Web phpinfo says `Loaded Configuration File /Library/Application Support/appsolute/MAMP PRO/conf/php.ini`.
Why are these different...? The Web version isn't even using the php.ini based on the version of PHP I'm using, it appears to be using a generic version... is this file overwritten by a version-specific one when I change PHP versions? I use the Module way to switch.
I'm confused on this all. Am I not supposed to modify `MAMP_timezone_MAMP`? Am I supposed to modify `/Applications/MAMP/bin/php/php[version]/conf/php.ini` directly?!
I looked for a setting in the MAMP UI but I saw nothing about setting time zone for either the server, the PHP version, the CLI, or the app.
When I run `die(phpinfo());` in my .php script through CLI, it shows this in the output:
date
Default timezone => Europe/Berlin
date.timezone => Europe/Berlin => Europe/Berlin
When I run `phpinfo()` through the normal web server, it shows correctly:
date
Default timezone America/Denver
Directive Local Value Master Value
date.timezone America/Denver America/Denver
When I look up how to change it for CLI, I find this page:
https://documentation.mamp.info/en/MAMP ... .ini-file/
When I click into MAMP > File > Open Template > PHP (php.ini) > PHP [the version I'm using], it opens `php[version].ini`, and under `[Date]` shows `date.timezone = MAMP_timezone_MAMP`. When I comment that line out and make a new one as `date.timezone = America/Denver` then restart MAMP, nothing changes in CLI or Web... apparently the instructions are wrong or incomplete.
CLI phpinfo says `Loaded Configuration File => /Applications/MAMP/bin/php/php[version]/conf/php.ini`.
Web phpinfo says `Loaded Configuration File /Library/Application Support/appsolute/MAMP PRO/conf/php.ini`.
Why are these different...? The Web version isn't even using the php.ini based on the version of PHP I'm using, it appears to be using a generic version... is this file overwritten by a version-specific one when I change PHP versions? I use the Module way to switch.
I'm confused on this all. Am I not supposed to modify `MAMP_timezone_MAMP`? Am I supposed to modify `/Applications/MAMP/bin/php/php[version]/conf/php.ini` directly?!
I looked for a setting in the MAMP UI but I saw nothing about setting time zone for either the server, the PHP version, the CLI, or the app.