DateTime():tz()
DateTime オブジェクトのタイムゾーンを指定したタイムゾーン ID に設定します。
シグネチャ
tz(timeZoneId: string): DateTime
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
timeZoneId | string | 設定するタイムゾーンの ID(例: "America/New_York", "Europe/London")。利用可能なタイムゾーン ID の一覧はこちらで確認できます。 |
戻り値
- 型:
DateTime - 現在の
DateTimeインスタンス。タイムゾーンが指定した ID に設定され、メソッドチェーンが可能です。
例
local now = DateTime()
toast("Local time: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))
now:tz("America/New_York")
toast("New York time: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))
now:tz("Europe/London")
toast("London time: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))