How to Set PHP Timezone Using .htaccess (hPanel’s File Manager + FTP)
In this article, we will show you how to change the PHP date.timezone on your website using the .htaccess file. Let’s take a look!
Changing PHP date.timezone with .htacess File
Before we go any further, make sure you know which timezone you want to use for your site. You can refer to this manual for a list of available timezones.
How to Change PHP date.timezone Through hPanel
.htaccess is a file located in public_html directory that you can edit using the File Manager on your Hostinger account, or via an FTP Client like FileZilla.
- Login to your hPanel and navigate to the File Manager under Files.
- Scroll down and locate the .htaccess file. If it’s not available, click on Create a new file option in the upper part of the page.
- Right-click on the file and select Edit.
- Enter the following code at the very top of your .htaccess code:
php_value date.timezone 'country/state'
Here we’re using “America/Chicago” as an example.
- Click Save & Close when you’re done.
How to Change PHP date.timezone Using an FTP client
You can also edit the .htacess file with an FTP client, such as FileZilla:
- Begin by configuring your FileZilla client.
- Connect to the server and find .htacess file, right-click and press View/Edit.
- Once the text editor pops out, use the same code from before:
php_value date.timezone 'country/state'
Click Save when you’re done.
- Check the “Finish editing and delete local file” option before clicking Yes.
- That’s it! The file will be uploaded to your server and you’ll be all set.
How to Verify If Your New Settings Are Live
To verify and see the changes you make, here’s what you can do:
- Create a new phpinfo.php file on public_html directory.
- Edit the file and insert the following code:
<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>
- Save your changes. Open a new tab on your browser.
- Go to your website by adding phpinfo.php at the end of your URL.
- Scroll down to find the date.timezone information table.
Congratulations, you have successfully changed the time zone of your website!
Conclusion
Here’s how to change PHP data.timezone using .htaccess. In summary, there are two ways how you can accomplish this:
- Over your Hostinger account’s hPanel.
- Using an FTP client and editing the file.
That was pretty easy, right?