isdst
Tests whether datetime values fall in daylight saving time.
Category: Language Fundamentals > Data Types
Syntax
tf = isdst(t)
Returns a logical array telling which elements of the datetime array t are in daylight saving time.
Description
A datetime with a time zone carries the rules of that zone, including the dates when clocks move forward and back. isdst consults those rules for each element.
A datetime with no time zone has no rules to apply, so the result is false everywhere.
Input arguments
t- datetime array. It needs a time zone to give a meaningful answer.
Output arguments
tf- Logical array the same size as
t;truewhere daylight saving time is in effect.
Example
Winter and summer in New York
w = datetime(2024,1,15,'TimeZone','America/New_York');
s = datetime(2024,7,15,'TimeZone','America/New_York');
isdst(w)
isdst(s)
Output
ans = logical
0
ans = logical
1