PHP code example of baspa / laravel-timezones

1. Go to this page and download the library: Download baspa/laravel-timezones library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baspa / laravel-timezones example snippets


use Baspa\Timezones\Facades\Timezones;
// 
$groupedTimezones = Timezones::toArray(grouped: true);

use Baspa\Timezones\Facades\Timezones;
// 
$timezones = Timezones::toArray();

use Baspa\Timezones\Facades\Timezones;
// 
$timezones = Timezones::excludeContinents(['Africa', 'America'])
    ->toArray();

$timezones = Timezones::showOffset()->toArray();
// or
$timezones = Timezones::showOffset(showOffset: false)->toArray();

$timezones = Timezones::

// Basic usage with country names
$timezones = Timezones::showCountry()->toArray();
// Output: "Amsterdam (Netherlands)"

// Combined with other methods
$timezones = Timezones::showCountry()
    ->showOffset(false)
    ->toArray();
// Output: "Amsterdam (Netherlands)"

// With full continent names preserved
$timezones = Timezones::showCountry()->toArrayWithContinents();
// Output: "Europe / Amsterdam (Netherlands)"

// Grouped by continent with country names
$timezones = Timezones::showCountry()->toArray(grouped: true);