# metricool/2.1.1/app/Features/UserSettings/Rules/TimezoneRule.php

Metricool – Social media and site statistics, version 2.1.1. 30 lines.

- Page: https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Features/UserSettings/Rules/TimezoneRule.php
- Raw: https://pluginprobe.com/plugins/metricool/2.1.1/raw/app/Features/UserSettings/Rules/TimezoneRule.php
- Modified: 2026-08-20T14:08:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Features/UserSettings/Rules/TimezoneRule.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Metricool\Features\UserSettings\Rules;

use Metricool\Support\Validation\Rules\AbstractRule;

class TimezoneRule extends AbstractRule
{
    /**
     * Checks if the value is a valid timezone identifier
     * @inheritDoc
     */
    public function validate(string $field, $value, array $data): void
    {
        $validTimezones = timezone_identifiers_list();

        if (!in_array($value, $validTimezones)) {
            $this->fail(esc_html(
                sprintf(
                    // translators: %s is the invalid timezone submitted by the user.
                    __('%s is not a valid timezone', 'metricool'),
                    $value
                )
            ));
        }
    }
}

```
