> ## Documentation Index
> Fetch the complete documentation index at: https://kb.stablepoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting timezones in PHP

PHP scripts use the server's default timezone unless told otherwise. If your application shows the wrong times — timestamps a few hours off, scheduled tasks firing at unexpected hours — setting the correct timezone usually fixes it.

## Method 1: Set the timezone in cPanel (recommended)

1. Log in to cPanel.
2. Open **MultiPHP INI Editor** (or **Select PHP Version** → **Options**, depending on your server).
3. Select your domain.
4. Find the **date.timezone** setting.
5. Enter your timezone identifier, for example `Europe/London` or `America/New_York`.
6. Save.

This applies to all PHP scripts on the domain. You can find the full list of valid timezone identifiers at [https://www.php.net/manual/en/timezones.php](https://www.php.net/manual/en/timezones.php).

## Method 2: Set the timezone in .htaccess

Add this line to the *.htaccess* file in your document root:

```text theme={null}
SetEnv TZ Europe/London
```

## Method 3: Set the timezone in your PHP code

At the top of your script (or in a shared include):

```php theme={null}
<?php
date_default_timezone_set('Europe/London');
```

This affects only the script(s) where it runs, which is useful if different parts of an application need different timezones.

## Application-level settings

Many applications have their own timezone setting that overrides or complements PHP's:

* **WordPress:** Settings → General → Timezone
* **Laravel:** the timezone key in config/app.php

<Note>
  Database timestamps are a separate concern — MySQL has its own timezone handling. If you store times in the database, it's best practice to store them in UTC and convert for display.
</Note>

## Verifying the change

Create a file containing:

```php theme={null}
<?php
echo date_default_timezone_get() . ' — ' . date('Y-m-d H:i:s');
```

Visit it in your browser to confirm the active timezone and current time, then delete the file.
