Configure php directives in cPanel

epiz_23213874
lovebug.epizy.com

I keep changing the timezone setting to Europe/London

at first if I display the time on a test page with <?php echo date('Y-m-d H:i:s'); ?> it will show the correct time but after a few minutes it’ll display the american time and checking in Cpanel shows that the time zone has reverted back to the default as shown here

Untitled-1

Add this directly to your .htaccess file:

php_value date.timezone Europe/London
5 Likes

I could do that or I could even set the time zone from the php but why does the time zone keep resetting after I change it in cPanel ?

thanks for that it seems to remember the setting and even shows correct in cpanel sorry I mean vistaPanel

Hmm…weird. This shouldn’t happen to often. I think this is some sort of bug or glitch.

1 Like

When and where do you see the time zone revert?

As far as I know, the time zone is only changed if you click the “Alter PHP Directives” button in the control panel (or manually set it in PHP or .htaccess, of course). If the New York timezone is selected there when you hit that button, the time zone will be set to New York.

It’s possible that the control panel doesn’t correctly read the current setting from your configuration file. So if you go to the control panel page, it always shows the New York time zone, regardless of what’s actually on your site. And if you then click the button, that time zone is set.

1 Like

while monitoring the time on my website test page as soon as i see the time change from london to america time (usually a few mins) I go back to cPanel https://cpanel.epizy.com/panel/indexpl.php?option=phpchangeconfig_configure and click on alter php directive and thats when I see that the timezone has changed back to america

but since ive added the code to the .htaccess file I see that the timezone stays on london in the webpage and in the cpanel

I’m sorry, just to make sure I’m understanding your message correctly:

You’re saying that you are setting the time zone to London, and then out of the blue it reverts to New York time? You don’t access the Alter PHP Directives menu in between at all?

that is correct Admin, strange right. it alters itself after a few mins

and the only thing that has stopped it is to use the trick of .htaccess suggested by TigerMANEK426

The Alter PHP Directives works by editing the .htaccess with the exact code that @TigerMANEK426 provided too.

Did you overwrite the .htaccess file with a local copy or something like that? That would explain why the setting “alters itself”. It’s not altering itself, you’re altering it by overwriting the configuration.

its possible that there was an htaccess file when i first signed up for an account and it may have gotten deleted, honestly I couldnt say, the only file I remember deleting was index.html

I did create a htaccess file recently for custom error pages

would you possibly have a copy of an original .htaccess file for a new account in case there is something vital missing from mine so I can join it to my own, thanks

— edit ----
I just looked and there is a .htaccess file in the root directory just before the htdocs direcrory but theres nothing in there about timezones
.htaccess (698 Bytes)

When you use the Alter PHP Directives tool, it applies the configuration like time zones by writing it to the .htaccess file in the htdocs folder of your website.

The .htaccess in the root directory doesn’t have anything to do with this.

3 Likes

ah thanks for explaining that

ok so the issue is this, when I use the alter php directives tool to change time zone nothing was written to my .htaccess in the htdocs folder !

im going to try again, i’ll set it to another time zone and see if it gets written this time

interesting, I just changed the timezone in cPanel from Europe/London to america/denva and downloaded my .htaccess file and I see three lines were written into it ( this wasnt happening originally and nothing was written into .htaccess )

php_value display_errors Off
php_value mbstring.http_input auto
php_value date.timezone America/Denver

experiment #2
removed the lines and uploaded .htaccess then checked the time is back to the default again

back to cpanel changed timezone to Europe/London and downloaded the .htaccess file and the 3 lines are back and time is correct

so for some weird reason the three lines wasnt getting written originally but now they are

thanks all good now

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.