tzoffset
Offset from UTC of the time zone of a datetime.
Category: Language Fundamentals > Data Types
Syntax
dt = tzoffset(d)
Returns the offset from UTC that applies at each datetime in d.
Description
The value depends on the date, not only the zone: New York is at -05:00 in winter and -04:00 in summer. A datetime with no time zone has no offset, and tzoffset returns NaN durations for it.
To see a zone's name use the TimeZone property, and to list valid zone names use timezones.
Input arguments
d- datetime array that has a time zone.
Output arguments
dt- Duration array: the local time minus UTC, including any daylight saving shift on that date.
Example
Offsets in three zones
d = datetime(2024,7,1,'TimeZone','America/New_York');
tzoffset(d)
tzoffset(datetime(2024,1,1,'TimeZone','America/Sao_Paulo'))
tzoffset(datetime(2024,1,1,'TimeZone','UTC'))
Output
ans = duration
-04:00
ans = duration
-03:00
ans = duration
00:00