XXII. Data i Czas
Wstęp
Funkcje te pozwalają Tobie pobrać datę i czas z serwera na którym uruchomione są Twoje skrypty. Możesz uzyć tych funkcji do formatowania daty i czasu na wiele różnych sposobów.
Notatka: Proszę pamiętać, że poniższe funkcje są zależne od lokalnych ustawień danego serwera. Upewnij się, że bieżesz czas zimowy (użyj np. $date = strtotime('+7 days', $date), a nie $date += 7*24*60*60) i lata przestępne pod uwagę kiedy pracujesz z tymi funkcjami.
Notatka: Strefy czasowe do których odwołujemy się w tym rozdziale możesz znaleźć w Dodatek H.
Wymagania
Do zbudowania tego rozszerzenia nie są wymagane żadne zewnętrzne biblioteki.
Instalacja
By używać tych funkcji, nie trzeba niczego instalować. Są one częścią jądra PHP.
Konfiguracja czasu wykonywania
To rozszerzenie nie definiuje posiada żadnych dyrektyw konfiguracyjnych w pliku php.ini.
Konfiguracja czasu wykonywania
Na działanie tych funcji wpływają ustawienia zawarte w pliku php.ini.
Tabela 1. Date/Time Configuration Options
| Name | Default | Changeable | Changelog |
|---|---|---|---|
| date.default_latitude | "31.7667" | PHP_INI_ALL | Available since PHP 5.0.0. |
| date.default_longitude | "35.2333" | PHP_INI_ALL | Available since PHP 5.0.0. |
| date.sunrise_zenith | "90.83" | PHP_INI_ALL | Available since PHP 5.0.0. |
| date.sunset_zenith | "90.83" | PHP_INI_ALL | Available since PHP 5.0.0. |
| date.timezone | "" | PHP_INI_ALL | Available since PHP 5.1.0. |
Oto krótkie wyjaśnienie dyrektyw konfiguracji.
- date.default_latitude float
-
The default latitude.
- date.default_longitude float
-
The default longitude.
- date.sunrise_zenith float
-
The default sunrise zenith.
- date.sunset_zenith float
-
The default sunset zenith.
- date.timezone string
-
The default timezone used by all date/time functions if the TZ environment variable isn't set. The precedence order is described in the date_default_timezone_get() page.
Notatka: The first four configuration options are currently only used by date_sunrise() and date_sunset().
Typy zasobów
To rozszerzenie nie posiada żadnych rodzajów zasobów.
Stałe predefinopwane
The following constants are defined since PHP 5.1.1 and they offer standard date representations, which can be used along with the date format functions (like date()).
- DATE_ATOM (string)
-
Atom (example: 2005-08-15T15:52:01+00:00)
- DATE_COOKIE (string)
-
HTTP Cookies (example: Monday, 15-Aug-05 15:52:01 UTC)
- DATE_ISO8601 (string)
-
ISO-8601 (example: 2005-08-15T15:52:01+0000)
- DATE_RFC822 (string)
-
RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)
- DATE_RFC850 (string)
-
RFC 850 (example: Monday, 15-Aug-05 15:52:01 UTC)
- DATE_RFC1036 (string)
-
RFC 1036 (example: Mon, 15 Aug 05 15:52:01 +0000)
- DATE_RFC1123 (string)
-
RFC 1123 (example: Mon, 15 Aug 2005 15:52:01 +0000)
- DATE_RFC2822 (string)
-
RFC 2822 (Mon, 15 Aug 2005 15:52:01 +0000)
- DATE_RSS (string)
-
RSS (Mon, 15 Aug 2005 15:52:01 +0000)
- DATE_W3C (string)
-
World Wide Web Consortium (example: 2005-08-15T15:52:01+00:00)
- Spis treści
- checkdate -- Waliduje datę gregoriańską
- date_default_timezone_get -- Gets the default timezone used by all date/time functions in a script
- date_default_timezone_set -- Sets the default timezone used by all date/time functions in a script
- date_sunrise -- Returns time of sunrise for a given day and location
- date_sunset -- Returns time of sunset for a given day and location
- date -- Formatuje lokalny czas/datę
- getdate -- Pobiera informację o dacie/czasie
- gettimeofday -- Pobiera aktualny czas
- gmdate -- Formatuje datę/czas dla strefy GMT/UTC
- gmmktime -- Ustala uniksowy znacznik czasu dla daty ze strefy GMT
- gmstrftime -- Formatuje czas/datę ze strefy GMT/UTC zgodnie z lokalizacją
- idate -- Format a local time/date as integer
- localtime -- Pobiera czas lokalny
- microtime -- Zwraca aktualny uniksowy znacznik czasu z mikrosekundami
- mktime -- Oblicza uniksowy znacznik czasu dla podanej daty
- strftime -- Formatuje lokalną datę/czas zgodnie z lokalizacją
- strptime -- Parse a time/date generated with strftime()
- strtotime -- Parsuje większość angielskich tekstowych opisów daty i czasu do uniksowego znacznika czasu
- time -- Zwraca aktualny uniksowy znacznik czasu
| Poprzedni | Spis treści | Następny |
| cyrus_unbind | Początek rozdziału | checkdate |