본문으로 건너뛰기

DateTime():tz()

DateTime 객체의 표준 시간대를 지정한 표준 시간대 ID로 설정합니다.

시그니처

tz(timeZoneId: string): DateTime

매개변수

매개변수유형설명
timeZoneIdstring설정할 표준 시간대의 ID (예: "America/New_York", "Europe/London"). 사용 가능한 표준 시간대 ID 목록은 여기에서 확인할 수 있습니다.

반환값

  • 유형: DateTime
  • 현재 DateTime 인스턴스이며, 표준 시간대가 지정한 ID로 설정되어 메서드 체이닝이 가능합니다.

예시

local now = DateTime()
toast("로컬 시간: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))

now:tz("America/New_York")
toast("뉴욕 시간: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))

now:tz("Europe/London")
toast("런던 시간: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))