Page 1 of 1

Changing PHP timezone not working

Posted: Tue Nov 15, 2022 12:40 am
by polera
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.

Re: Changing PHP timezone not working

Posted: Tue Nov 15, 2022 5:41 pm
by polera
I'm trying to fix by just editing the file directly, but I've read that we shouldn't be doing that... but I'm not seeing what I should be doing.

So far it's working, though I don't know yet if it'll work between restarts or cause an issue anywhere.

I think if MAMP's going to have a shortcut like `MAMP_timezone_MAMP` in the template file it recommends to modify, that this should relate to a setting in the GUI. I don't know, maybe I'm just being a silly person

Re: Changing PHP timezone not working

Posted: Fri Nov 18, 2022 4:45 pm
by polera
I got it to work by modifying `/Applications/MAMP/bin/php/php[version]/conf/php.ini` directly... which I thought we weren't supposed to do.

So, I don't see a better solution.

Surprising nobody answered.

Re: Changing PHP timezone not working

Posted: Mon Nov 21, 2022 10:53 am
by mampsupportmod
Thanks for sharing. Might be worth bringing up on their bug base: https://bugs.mamp.info/my_view_page.php

I'm anxiously awaiting MAMP Pro 7.0 + new builds which hopefully address a lot of the oddities in previous versions I've reported