라이브러리

[PHP] IntlDateFormatter::getPattern - IntlDateFormatter에 사용된 패턴을 가져옵니다.




IntlDateFormatter::getPattern

PHP의 IntlDateFormatter 클래스는 국제 날짜 및 시간 형식을 처리하는 데 사용됩니다. IntlDateFormatter::getPattern 메서드는 지정된 지역의 날짜 및 시간 형식을 문자열로 반환합니다.

사용법


IntlDateFormatter::getPattern 메서드는 다음과 같은 형식으로 사용됩니다.

#hostingforum.kr
php

IntlDateFormatter::getPattern($locale, $dateType, $timeType, $patternType)



- `$locale` : 지역 코드 (예: 'ko_KR', 'en_US')
- `$dateType` : 날짜 형식 (예: IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT)
- `$timeType` : 시간 형식 (예: IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT)
- `$patternType` : 패턴 형식 (예: IntlDateFormatter::PATTERN_ALL, IntlDateFormatter::PATTERN_DEFAULT)

예제


#hostingforum.kr
php

// 지역 코드, 날짜 형식, 시간 형식, 패턴 형식 지정

$locale = 'ko_KR';

$dateType = IntlDateFormatter::FULL;

$timeType = IntlDateFormatter::FULL;

$patternType = IntlDateFormatter::PATTERN_ALL;



// IntlDateFormatter 객체 생성

$formatter = new IntlDateFormatter($locale, $dateType, $timeType, $patternType);



// IntlDateFormatter::getPattern 메서드 호출

$pattern = $formatter->getPattern();



// 결과 출력

echo "지역 코드: $locale
";

echo "날짜 형식: $dateType
";

echo "시간 형식: $timeType
";

echo "패턴 형식: $patternType
";

echo "패턴: $pattern
";



결과


#hostingforum.kr


지역 코드: ko_KR

날짜 형식: FULL

시간 형식: FULL

패턴 형식: PATTERN_ALL

패턴: yyyy년 MM월 dd일 EEEE HH:mm:ss



IntlDateFormatter::getPattern 메서드의 사용 사례


IntlDateFormatter::getPattern 메서드는 다음의 사용 사례가 있습니다.

- 지역별 날짜 및 시간 형식을 처리하는 데 사용됩니다.
- 날짜 및 시간 형식을 문자열로 변환하는 데 사용됩니다.
- 날짜 및 시간 형식을 비교하거나 검증하는 데 사용됩니다.

IntlDateFormatter::getPattern 메서드의 제한 사항


IntlDateFormatter::getPattern 메서드는 다음의 제한 사항이 있습니다.

- 지역 코드가 잘못된 경우 예외가 발생합니다.
- 날짜 형식, 시간 형식, 패턴 형식이 잘못된 경우 예외가 발생합니다.
- 날짜 및 시간 형식이 잘못된 경우 예외가 발생합니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 442 페이지

검색

게시물 검색