라이브러리
[PHP] IntlDateFormatter::localtime - 문자열을 필드 기반 시간 값으로 구문 분석
IntlDateFormatter::localtime은 PHP의 IntlDateFormatter 클래스에 속하는 메서드입니다. 이 메서드는 현재 시스템의 로컬 시간을 반환합니다.
IntlDateFormatter::localtime 사용법
IntlDateFormatter::localtime 메서드는 IntlDateFormatter 객체를 통해 호출됩니다. IntlDateFormatter 객체는 IntlDateFormatter 클래스의 생성자 함수를 통해 생성됩니다.
# IntlDateFormatter 클래스의 생성자 함수
- `$locale`: 사용할 지역 설정입니다. 예를 들어 'ko_KR'은 한국어로 설정합니다.
- `$dateType`: 날짜 형식입니다. 예를 들어 IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등이 있습니다.
- `$timeType`: 시간 형식입니다. 예를 들어 IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등이 있습니다.
- `$timezone`: 사용할 시간대입니다. 예를 들어 'Asia/Seoul'은 한국 시간대입니다.
- `$pattern`: 사용할 형식입니다. 예를 들어 'yyyy-MM-dd HH:mm:ss'과 같은 형식이 있습니다.
# IntlDateFormatter::localtime 메서드
IntlDateFormatter::localtime 메서드는 IntlDateFormatter 객체를 통해 호출됩니다.
- `$date`: 반환할 날짜입니다.
예제
참고
IntlDateFormatter::localtime 메서드는 현재 시스템의 로컬 시간을 반환합니다. 따라서 시스템의 시간대가 변경되면 반환되는 시간도 변경됩니다.
IntlDateFormatter::create 메서드는 IntlDateFormatter 객체를 생성합니다. 이 객체를 통해 IntlDateFormatter::localtime 메서드를 호출할 수 있습니다.
IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등은 날짜 형식입니다. IntlDateFormatter::FULL은 전체 날짜 형식, IntlDateFormatter::LONG은 장 날짜 형식, IntlDateFormatter::MEDIUM은 중간 날짜 형식, IntlDateFormatter::SHORT은 짧은 날짜 형식입니다.
IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등은 시간 형식입니다. IntlDateFormatter::FULL은 전체 시간 형식, IntlDateFormatter::LONG은 장 시간 형식, IntlDateFormatter::MEDIUM은 중간 시간 형식, IntlDateFormatter::SHORT은 짧은 시간 형식입니다.
IntlDateFormatter::create 메서드는 지역 설정, 날짜 형식, 시간 형식, 시간대, 형식 등을 지정할 수 있습니다.
IntlDateFormatter::localtime 사용법
IntlDateFormatter::localtime 메서드는 IntlDateFormatter 객체를 통해 호출됩니다. IntlDateFormatter 객체는 IntlDateFormatter 클래스의 생성자 함수를 통해 생성됩니다.
# IntlDateFormatter 클래스의 생성자 함수
#hostingforum.kr
php
IntlDateFormatter::create($locale, $dateType, $timeType, $timezone, $pattern)
- `$locale`: 사용할 지역 설정입니다. 예를 들어 'ko_KR'은 한국어로 설정합니다.
- `$dateType`: 날짜 형식입니다. 예를 들어 IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등이 있습니다.
- `$timeType`: 시간 형식입니다. 예를 들어 IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등이 있습니다.
- `$timezone`: 사용할 시간대입니다. 예를 들어 'Asia/Seoul'은 한국 시간대입니다.
- `$pattern`: 사용할 형식입니다. 예를 들어 'yyyy-MM-dd HH:mm:ss'과 같은 형식이 있습니다.
# IntlDateFormatter::localtime 메서드
IntlDateFormatter::localtime 메서드는 IntlDateFormatter 객체를 통해 호출됩니다.
#hostingforum.kr
php
IntlDateFormatter::localtime($date)
- `$date`: 반환할 날짜입니다.
예제
#hostingforum.kr
php
// 현재 시스템의 로컬 시간을 반환합니다.
$date = new DateTime();
$formatter = IntlDateFormatter::create('ko_KR', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
echo $formatter->format($date) . "
";
// 2024-02-14 14:30:00
참고
IntlDateFormatter::localtime 메서드는 현재 시스템의 로컬 시간을 반환합니다. 따라서 시스템의 시간대가 변경되면 반환되는 시간도 변경됩니다.
IntlDateFormatter::create 메서드는 IntlDateFormatter 객체를 생성합니다. 이 객체를 통해 IntlDateFormatter::localtime 메서드를 호출할 수 있습니다.
IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등은 날짜 형식입니다. IntlDateFormatter::FULL은 전체 날짜 형식, IntlDateFormatter::LONG은 장 날짜 형식, IntlDateFormatter::MEDIUM은 중간 날짜 형식, IntlDateFormatter::SHORT은 짧은 날짜 형식입니다.
IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT 등은 시간 형식입니다. IntlDateFormatter::FULL은 전체 시간 형식, IntlDateFormatter::LONG은 장 시간 형식, IntlDateFormatter::MEDIUM은 중간 시간 형식, IntlDateFormatter::SHORT은 짧은 시간 형식입니다.
IntlDateFormatter::create 메서드는 지역 설정, 날짜 형식, 시간 형식, 시간대, 형식 등을 지정할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.