날짜와 시간 함수
소개
이 함수들은 PHP가 실행되고 있는 서버로부터 날짜와 시간을 얻을 수 있게 합니다. 여러가지 다른 방법으로 날짜와 시간 출력을 형식화할 수 있습니다.
Note: 이 함수들은 서버의 지역설정에 의존한다는 점을 명심하십시오. 특히 윤년과 일광 절약 시간을 생각해서 작업하십시오. (즉, $date += 7*24*60*60이 아니라 $date = strtotime('+7 days'), $date)을 사용하십시오)
Note: 이 섹션에서 참고하는 타임존은 List of Supported Timezones에서 볼 수 있습니다.
요구 조건
이 확장을 빌드할 때 외부 라이브러리가 필요하지 않습니다.
설치
이 함수들은 설치하지 않아도 사용할 수 있습니다; PHP 코어의 일부입니다.
Note: 최신 버전의 타임존 데이터베이스는 PECL » timezonedb를 통해 설치할 수 있습니다. 윈도우 사용자는 PECL4Win 사이트에서 컴파일 된 DLL을 받을 수 있습니다: » php_timezonedb.dll
실행시 설정
이 함수의 작동은 php.ini 설정에 영향을 받습니다.
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.583333" | PHP_INI_ALL | Available since PHP 5.0.0. |
date.sunset_zenith | "90.583333" | PHP_INI_ALL | Available since PHP 5.0.0. |
date.timezone | "" | PHP_INI_ALL | Available since PHP 5.1.0. |
위 설정 지시어에 대한 간단한 설명입니다.
- 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 List of Supported Timezones for a list of supported timezones.
Note: The first four configuration options are currently only used by date_sunrise() and date_sunset().
자원형
이 확장은 리소스형을 정의하지 않습니다.
예약 상수
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().
Table of Contents
- checkdate — 그레고리안력 날짜를 확인합니다.
- 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 — 로컬 날짜/시간을 형식화합니다.
- getdate — 날짜/시간 정보를 가져온다
- gettimeofday — Get current time
- gmdate — Format a GMT/UTC date/time
- gmmktime — Get Unix timestamp for a GMT date
- gmstrftime — Format a GMT/UTC time/date according to locale settings
- idate — Format a local time/date as integer
- localtime — Get the local time
- microtime — Return current Unix timestamp with microseconds
- mktime — Get Unix timestamp for a date
- strftime — Format a local time/date according to locale settings
- strptime — Parse a time/date generated with strftime
- strtotime — Parse about any English textual datetime description into a Unix timestamp
- time — Return current Unix timestamp
- 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