Main Content

tzoffset

Time zone offset from UTC

Description

dt = tzoffset(t) returns an array of durations equal to the time zone offset from UTC of each datetime value in t. That is, dt is the amount of time that each datetime in t differs from UTC. For datetimes that occur during Daylight Saving Time (DST), dt includes the time shift for DST. The offset for unzoned datetime values is not defined.

example

[dt,dst] = tzoffset(t) additionally returns the time shift for Daylight Saving Time for each datetime in t.

example

Examples

collapse all

Create a datetime array in the time zone for New York City.

t1 = datetime('today','TimeZone','America/New_York');
t = dateshift(t1,'end','month',[1:3:9])
t = 1x3 datetime
   31-Aug-2024   30-Nov-2024   28-Feb-2025

Find the time zone offset from UTC and the time shift for Daylight Saving Time for each datetime value.

[dt,dst] = tzoffset(t)
dt = 1x3 duration
   -04:00   -05:00   -05:00

dst = 1x3 duration
   01:00   00:00   00:00

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Output Arguments

collapse all

Time zone offset from UTC, returned as a scalar, vector, matrix, or multidimensional duration array. dt is the same size as t.

Time shift for Daylight Saving Time, returned as a scalar, vector, matrix, or multidimensional duration array. dt is the same size as t. A value of 01:00 indicates that the corresponding datetime in t occurs during Daylight Saving Time in a location that observes it. For locations that do not observe Daylight Saving Time, the elements of the dst array are all 00:00.

Extended Capabilities

Version History

Introduced in R2014b

See Also