Changing PHP timezone not working

All MAMP discussions around troubleshooting and anything related to MAMP. Be as detailed as possible here when posting an issue.
Post Reply
polera
Posts: 14
Joined: Mon Jan 10, 2022 4:36 pm

Changing PHP timezone not working

Post 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.
polera
Posts: 14
Joined: Mon Jan 10, 2022 4:36 pm

Re: Changing PHP timezone not working

Post 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
polera
Posts: 14
Joined: Mon Jan 10, 2022 4:36 pm

Re: Changing PHP timezone not working

Post 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.
mampsupportmod
Site Admin
Posts: 161
Joined: Wed Jan 20, 2021 3:06 am

Re: Changing PHP timezone not working

Post 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
MAMP Support Forums is an unofficial support forum covering MAMP & MAMP Pro solution stacks.
Post Reply