
IntlGregorianCalendar::createFromDateTime 메서드는 DateTime 객체를 생성할 때 시간대 설정을 고려합니다.
시간대 설정은 DateTime 객체의 time zone을 지정할 때 사용됩니다. 예를 들어, Asia/Seoul 시간대를 지정하면 IntlGregorianCalendar::createFromDateTime 메서드의 시간대도 Asia/Seoul로 설정됩니다.
IntlGregorianCalendar::createFromDateTime 메서드는 DateTime 객체의 시간대 설정을 그대로 사용하기 때문에, DateTime 객체의 시간대 설정을 정확하게 지정해야 합니다.
DateTime 객체의 시간대 설정을 지정하는 방법은 다음과 같습니다.
- DateTime 객체 생성 시 time zone을 지정하는 방법
#hostingforum.kr
php
$date = new DateTime('2022-01-01 12:00:00', new DateTimeZone('Asia/Seoul'));
- DateTimeZone 객체를 사용하는 방법
#hostingforum.kr
php
$dateTimeZone = new DateTimeZone('Asia/Seoul');
$date = new DateTime('2022-01-01 12:00:00', $dateTimeZone);
IntlGregorianCalendar::createFromDateTime 메서드의 시간대 설정은 DateTime 객체의 시간대 설정과 동일합니다. 따라서 DateTime 객체의 시간대 설정을 정확하게 지정해야 합니다.
2025-08-01 21:49