Skip to content

Function: toTimezone()

ts
function toTimezone(date, timezone): Date;

Convert date to different timezone. 将日期转换为不同时区。

Parameters

ParameterTypeDescription
dateDateSource date / 源日期
timezonestringIANA timezone string / IANA 时区字符串

Returns

Date

New Date adjusted to the target timezone / 调整到目标时区的新 Date

Example

ts
const d = new Date('2024-01-15')
toTimezone(d, 'America/New_York') // Date in New York time

Since

1.0.0

Released under the MIT License.