Dec 22, 2025
Jordana A.
4min Read
PHP defaults to Coordinated Universal Time (UTC) regardless of your server’s timezone. Configuring the PHP timezone accurately is crucial for precise data management and time-sensitive operations like logging and scheduling.
This practice is especially vital for web applications with global audiences outside the UTC timezone. For instance, it makes handling daylight saving time easier.
You can change your website’s PHP timezone settings using the PHP function or by modifying the .htaccess or php.ini files. This article will explore each method so that you can choose the most suitable one for your needs.

The date_default_timezone_set() function sets a script’s default timezone for all date and time functions. It ensures accurate handling of time-related data in PHP web applications, even if your web hosting server is in a different timezone than you or your target audience.
The list of supported timezones is available on PHP’s official website. Double-check using the timezone abbreviation list to ensure you select the correct timezone.
Here’s an example of how to use the date_default_timezone_set() function:
<?php
date_default_timezone_set('America/New_York');
?>If you’re working on a standalone PHP script or a simple project, place the function at the top of your file before any timezone-related PHP functions are called. However, setting the timezone in the configuration or bootstrap file is best for larger projects.
You can find your website’s configuration file in the root directory called public_html. While the file name varies depending on the CMS used, it’s usually named config.php.
Changing the PHP date.timezone setting using the .htaccess file is often done in shared hosting environments where the php.ini file is inaccessible. The .htaccess file lets you override server configurations for specific directories, including the timezone setting.
The .htaccess file is accessible using a file manager, an FTP client, and SSH. Using the hosting account’s file manager should be the easiest method for beginners.
Here’s how to change your website’s default timezone in the .htaccess file using Hostinger’s File Manager:
php_value date.timezone 'country/state'

You can also modify the PHP timezone setting by editing the .htaccess file with an FTP client, such as FileZilla. Hostinger users can find their FTP details in Files → FTP Accounts on hPanel.
Here’s how to modify the PHP default timezone in the .htaccess file using the FileZilla FTP client:
php_value date.timezone 'country/state'
Secure Shell Protocol (SSH) is a remote administration protocol that provides direct access and control over server files. It ensures secure data transmission across remote servers from the terminal window, making it a popular choice for experienced command-line users.
In this tutorial, we’re using PuTTY, a popular SSH client. Check out our article on how to use the PuTTY SSH client to access your server.
Follow these steps to change the date.timezone value with the PuTTY SSH client:
php -i | grep "date.timezone"
timedatectl list-timezones
timedatectl set-timezone [region/location]
If you encounter an error during the configuration process, try these solutions:
Setting the desired timezone in PHP scripts using the php.ini file is best for a global implementation across the site. This method ensures server-level consistency, which is crucial for server-side operations like cron jobs.
Eliminating repeated timezone settings in scripts also streamlines your PHP configuration, making your code cleaner and more efficient.
Follow these steps to set a new timezone in PHP using the php.ini file. We’re using Hostinger’s File Manager, but feel free to use an FTP client if that’s your preference.
date.timezone = "country/state"
service apache2 restart
A content delivery network is great for websites with a global audience. It stores your website in different data centers globally and sends data from the nearest location to the visitors. This network of servers speeds up your website and keeps your main server from getting overloaded. Get Hostinger CDN for free when buying Business or any of the Cloud hosting plans.
Setting the correct timezone in PHP is crucial for ensuring accurate and consistent date and time handling across your web applications. It helps you maintain a seamless user experience for a global audience, meet legal standards for time-sensitive data, and ensure reliable scheduling and logging.
Let’s recap three effective ways to change the timezone configuration in PHP:
We hope this article helped you understand the benefits and proper implementation of setting timezones in PHP scripts. Leave a comment if you have any questions. Good luck!