tzoffset - Time zone offset from UTC - MATLAB (original) (raw)
Main Content
Time zone offset from UTC
Syntax
Description
[dt](#bugc525-1-dt) = tzoffset([t](#bugc525-1%5Fsep%5Fshared-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.
[[dt](#bugc525-1-dt),[dst](#bugc525-1-dst)] = tzoffset([t](#bugc525-1%5Fsep%5Fshared-t))
additionally returns the time shift for Daylight Saving Time for each datetime int
.
Examples
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 = 1×3 datetime 31-Mar-2025 30-Jun-2025 30-Sep-2025
Find the time zone offset from UTC and the time shift for Daylight Saving Time for each datetime value.
dt = 1×3 duration -04:00 -04:00 -04:00
dst = 1×3 duration 01:00 01:00 01:00
Input Arguments
Input date and time, specified as a datetime
array.
Output Arguments
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 of01:00
indicates that the corresponding datetime int
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 all00:00
.
Extended Capabilities
Thetzoffset
function fully supports tall arrays. For more information, see Tall Arrays.
Version History
Introduced in R2014b