PHP 8.3.4 Released!

DateTimeZone sınıfı

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

Giriş

Zaman dilimi gösterimi.

Sınıf Sözdizimi

class DateTimeZone {
/* Sabitler */
const int AFRICA = 1;
const int AMERICA = 2;
const int ANTARCTICA = 4;
const int ARCTIC = 8;
const int ASIA = 16;
const int ATLANTIC = 32;
const int AUSTRALIA = 64;
const int EUROPE = 128;
const int INDIAN = 256;
const int PACIFIC = 512;
const int UTC = 1024;
const int ALL = 2047;
const int ALL_WITH_BC = 4095;
const int PER_COUNTRY = 4096;
/* Yöntemler */
public __construct(string $timezone)
timezone_open(string $timezone): DateTimeZone|false
timezone_location_get(DateTimeZone $nesne): array|false
public getName(DateTimeZone $nesne): string
public getOffset(DateTimeInterface $datetime): int
public getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false
public static listAbbreviations(): array
public static listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array
}

Öntanımlı Sabitler

DateTimeZone::AFRICA

Afrika zaman dilimleri.

DateTimeZone::AMERICA

Amerika zaman dilimleri.

DateTimeZone::ANTARCTICA

Antarktika zaman dilimleri.

DateTimeZone::ARCTIC

Kuzey Kutup Dairesi zaman dilimleri.

DateTimeZone::ASIA

Asya zaman dilimleri.

DateTimeZone::ATLANTIC

Atlantik zaman dilimleri.

DateTimeZone::AUSTRALIA

Avustralya zaman dilimleri.

DateTimeZone::EUROPE

Avrupa zaman dilimleri.

DateTimeZone::INDIAN

Hindistan zaman dilimleri.

DateTimeZone::PACIFIC

Pasifik zaman dilimleri.

DateTimeZone::UTC

UTC zaman dilimleri.

DateTimeZone::ALL

Tüm zaman dilimleri.

DateTimeZone::ALL_WITH_BC

Geriye uyumluluk dahil tüm zaman dilimleri.

DateTimeZone::PER_COUNTRY

Ülkelere göre zaman dilimleri.

İçindekiler

add a note

User Contributed Notes 1 note

up
4
Jarmo Troska
6 months ago
Example of converting between timezones using the DateTime and DateTimeZone classes.

Note that PHP will also take care of calculating relevant daylight savings!

<?php

$utc_timezone
= new DateTimeZone("UTC");

$tallinn_timezone = new DateTimeZone("Europe/Tallinn");

// Create a new DateTime object in the UTC format

$datetime = new DateTime("2023-01-01 11:00:00", $utc_timezone);

// Convert the DateTime object to the timezone of Tallinn

$datetime->setTimezone($tallinn_timezone);

// Display the result in the YYYY-MM-DD HH:MM:SS format

echo $datetime->format('Y-m-d H:i:s');

// Returns: 2023-01-01 13:00:00

?>
To Top