Nauka programowania php

Prosty kurs dla amatorów

Data i Czas

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.

Notatka: Najnowszą wersję bazy danych stref czasowych możesz zainstalować poprzez PECL timezonedb. Dla użytkowików Windows, prekompilowana biblioteka DLL może być pobrana ze strony PECL4WIN: php_timezonedb.dll.

Konfiguracja uruchomieniowa

To rozszerzenie nie definiuje posiada żadnych dyrektyw konfiguracyjnych w pliku php.ini.

Konfiguracja uruchomieniowa

Na działanie tych funcji wpływają ustawienia zawarte w pliku php.ini.

Tabela 1. Date/Time Configuration Options

NameDefaultChangeableChangelog
date.default_latitude"31.7667"PHP_INI_ALLAvailable since PHP 5.0.0.
date.default_longitude"35.2333"PHP_INI_ALLAvailable since PHP 5.0.0.
date.sunrise_zenith"90.83"PHP_INI_ALLAvailable since PHP 5.0.0.
date.sunset_zenith"90.83"PHP_INI_ALLAvailable since PHP 5.0.0.
date.timezone""PHP_INI_ALLAvailable since PHP 5.1.0.
Szczegóły i definicje dotyczące stałych PHP_INI_* znajdują się w rozdziale Dodatek G.

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. See Dodatek H for a list of supported timezones.

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 predefiniowane

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_RFC3339 (string)

Same as DATE_ATOM (since PHP 5.1.3)

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)

Following constants exists since PHP 5.1.2 and specify a format returned by functions date_sunrise() and date_sunset().

SUNFUNCS_RET_TIMESTAMP (integer)

Timestamp

SUNFUNCS_RET_STRING (integer)

Hours:minutes (example: 08:02)

SUNFUNCS_RET_DOUBLE (integer)

Hours as floating point number (example 8.75)

Spis treści
checkdate -- Waliduje datÄ™ gregoriaÅ„skÄ…
date_create -- Returns new DateTime object
date_date_set -- Sets the date
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_format -- Returns date formatted according to given format
date_isodate_set -- Sets the ISO date
date_modify -- Alters the timestamp
date_offset_get -- Returns the daylight saving time offset
date_parse -- Returns associative array with detailed info about given date
date_sun_info -- Returns an array with information about sunset/sunrise and twilight begin/end
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_time_set -- Sets the time
date_timezone_get -- Return time zone relative to given DateTime
date_timezone_set -- Sets the time zone for the DateTime object
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
timezone_abbreviations_list -- Returns associative array containing dst, offset and the timezone name
timezone_identifiers_list -- Returns numerically index array with all timezone identifiers
timezone_name_from_abbr -- Returns the timezone name from abbrevation
timezone_name_get -- Returns the name of the timezone
timezone_offset_get -- Returns the timezone offset from GMT
timezone_open -- Returns new DateTimeZone object
timezone_transitions_get -- Returns all transitions for the timezone


Newsy:

Nowości z listy dyskusyjnej

drugsxxx: Test (C/C++)
Mam taki test i co prawa ju¿ go pisa³em ale nie wiem jakie s± dobre odpowiedzi moze kto¶ mi pomo¿e??

http://www.kolejland.rail.pl/iz/Forum%20-%...wania/jipp2.jpg

Moje odpowiedzi to:

1. a
2. abc
3. bc
4. d
5. ad
morphix: Programik do wy¶wietlania informacji na pulpicie (Windows Programming)
Plisss bardzo potrzebny nam jest taki program!!!
fressbie: [C++, Assembler] Zlece napisanie lub modyfikacje (Oferujê pracê)
Witam,

Jak w temacie zlecê napisanie od nowa lub zmodyfikowanie istniej±cej ju¿ wersji programu do obliczania sum md5. Zainteresowanych proszê o kontakt.
bear007: Polska strona rozwa¿a przej¶cie na Open Source (Server-Side)
Autor strony Polishwords rozwa¿a przej¶cie na model Open Source. Aby u³atwiæ sobie decyzjê umie¶ci³ ankietê, w której mo¿na zag³osowaæ za albo przeciwko przej¶ciu na Open Source. Pomó¿my autorowi!

Strona Polishwords jest przeznaczona dla programistów i ogó³ informatyków. Zawiera filmy instrukta¿owe z programowania i zarz±dzania baz± danych. Autor rozwa¿a obecnie przej¶cie na model Open Source i opublikowanie kodu strony. Chcia³by przez to osi±gn±æ szybszy rozwój strony i zaanga¿owanie wiêkszej liczby programistów PHP.

W umieszczonej ankiecie mo¿na zag³osowaæ czy autor powinien przej¶æ na model Open Source. Pomó¿ podj±æ dobr± decyzjê autorowi.

Wiêcej na: http://polishwords.com.pl/blog/2008/polishwords-open-source/
webcoder: Program typu klient-serwer (Delphi/Pascal)
Witam pisze program klient-serwer. Próba nr.1:
Skorzysta³em z najprostszech komponentów tego rodzaju czyli ClientSocket i ServerSocket. Posutawialem porty oraz ip w kliencie.
Je¿eli wpsize ip localhosta (127.0.0.1) to klient polaczy sie z serwerem. Jezeli wpisze IP wewnetrzne tez sie polaczy. Ale jezeli wpisze juz ip zewnetrzne to wyskauje blad asynohrous socket error 10061.
Podejscie nr.2
Zmieni³em komponenty na Indy. Wszystko zosta³o odpowiednio skofigurowane. Wiec sytuacja jest identyczna jak powyzej wszystko dziala na ip wewnetrznym i na localhoscie a na zewnetrznym juz. Prosze o pomoc w tej sprawie.

Mo¿e jeszcze dodam, ¿e jest w sieci typu WLan.
Pozdro
Prosze o jak najszybsza odpowiedz

Jak nie znasz jezyka C++ i wskaznikow i programowania obiektowego, to sobie daruj programy okienkowe. Jezeli znasz to wszystko co wymienilem, to w sumie powinienes tez wiedziec jak, badz przy pomocy czego da sie tworzyc programy okienkowe piszac w C++

Kurs

Kurs powstał w celu nauki podstawowych zagadnień z dziedziny php.


Losowe tagi:

fribidi
image
mailparse
uodbc
pspell