
date_timezone_set 함수는 DateTime 객체에 시간대를 설정하는 함수입니다.
예를 들어, UTC-5 시간대를 현재 시간대로 설정하고 싶다면 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$date = new DateTime();
$date->setTimezone(new DateTimeZone('-05:00'));
이러한 방법으로 시간대를 변경할 수 있습니다.
만약 UTC+2 시간대를 설정하고 싶다면 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$date = new DateTime();
$date->setTimezone(new DateTimeZone('+02:00'));
또는 DateTimeZone 클래스를 사용하여 시간대를 생성할 수 있습니다.
#hostingforum.kr
php
$timezone = new DateTimeZone('Etc/GMT+2');
$date->setTimezone($timezone);
이러한 방법으로 시간대를 변경할 수 있습니다.
2025-03-27 14:42