DateTime::setTimestamp
DateTime::sub
DateTime
PHP Manual

# DateTime::setTimezone

(PHP 5 >= 5.2.0)

DateTime::setTimezone — Sets the time zone for the DateTime object

### 설명

public DateTime DateTime::setTimezone ( DateTimeZone `$timezone` )
DateTime date_timezone_set ( DateTime `$object` , DateTimeZone `$timezone` )

### 인수

`object`

  절차식 전용: date_create()가 반환하는 DateTime 객체.

`timezone`

  Desired time zone.

### 반환값

Returns the modified DateTime.

### 변경점

버전 | 설명
--- | ---
5.3.0 | Changed the return value from `NULL` to DateTime.

### 예제

Example #1 Setting and getting DateTimeZone objects

`<?php
date_default_timezone_set('Europe/London');
$datetime = new DateTime('2008-08-03 12:35:23');
echo $datetime->getTimezone()->getName() . "\n";
$datetime = new DateTime('2008-08-03 12:35:23');
$la_time = new DateTimeZone('America/Los_Angeles');
$datetime->setTimezone($la_time);
echo $datetime->getTimezone()->getName();
?>`

위 예제의 출력:

    Europe/London
    America/Los_Angeles

### 참고

- DateTime::getTimezone() - Return time zone relative to given DateTime
- timezone_open() - Returns new DateTimeZone object

DateTime::setTimestamp
DateTime::sub
DateTime
PHP Manual