datetime

Methods

Method Reference: datetime.tzoffset

datetime: DT = tzoffset (T)
datetime: [DT, DST] = tzoffset (T)

Time zone offset of a datetime array.

DT = tzoffset (T) returns the offset from UTC of each element of the input datetime array T as a duration array DT of the same size as T. The offset is positive for time zones east of UTC and includes the additional hour when daylight saving time is in effect. If T has no time zone, or for Not-A-Time (NaT) and infinite values, the corresponding offset is NaN.

[DT, DST] = tzoffset (T) also returns the daylight saving time part of each offset as a duration array DST: zero in standard time and in a time zone without daylight saving time, and NaN wherever DT is. Where the IANA database writes the winter of a time zone as a negative saving, as for 'Europe/Dublin' or 'Africa/Casablanca', the other half of the year is counted as the daylight saving time instead, and isdst agrees.

Source Code: datetime

tzoffset gives each element's offset from UTC as a duration. Because the offset depends on daylight saving time, the same zone reports a different value in winter and in summer.

 winter = datetime (2024, 1, 15, 'TimeZone', 'America/New_York')
winter =
  datetime

   15-Jan-2024
 tzoffset (winter)
ans =
  duration

   -05:00
 summer = datetime (2024, 7, 15, 'TimeZone', 'America/New_York')
summer =
  datetime

   15-Jul-2024
 tzoffset (summer)
ans =
  duration

   -04:00