antonchaikin/f3-timezone

Fat-Free Framework plugin to detect and set PHP timezone based on request headers, query, or body parameters.

Maintainers

👁 AppTor

Package info

github.com/AntonSeagull/f3-timezone

pkg:composer/antonchaikin/f3-timezone

Statistics

Installs: 16

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.3 2025-05-28 14:39 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 927cbaf18d6049c50dc93d7ae33d7087665e7f8d

This package is auto-updated.

Last update: 2026-06-28 16:59:23 UTC


README

Fat-Free Framework plugin to detect and set PHP timezone based on request data.

This plugin checks for timezone information in the incoming request (HEADERS, GET, POST, COOKIE, SESSION) and sets it globally using date_default_timezone_set().

💡 Installation

Require via Composer:

composer require antonchaikin/f3-timezone

Or add manually to composer.json:

"require": {
 "antonchaikin/f3-timezone": "^1.0"
}

🚀 Usage

In your index.php:

use F3Timezone\TimezonePlugin;

$f3 = \Base::instance();

// Register the plugin
TimezonePlugin::register();

// Set timezone from request
$f3->updateTimezone();

📦 What it does

  • Searches for a timezone value in:
    • HEADERS
    • GET
    • POST
    • COOKIE
    • SESSION
  • Accepts only valid PHP timezones
  • Automatically applies it using date_default_timezone_set(...)

✅ Example

If a client sends this header:

Timezone: Europe/Warsaw

The plugin will detect it and call:

date_default_timezone_set('Europe/Warsaw');

📝 License

MIT