File Exchange

image thumbnail

Daylight Savings Time

version (1.6 KB) by Nate
Checks if a date is during USA daylight savings time

1 Download

Updated 20 Jul 2011

View License

Function takes a date as a string in 'mm/dd/yyyy' format and outputs a
logical, true if the date is during daylight savings time for that year. See
definition of daylight savings time in the USA

Cite As

Nate (2021). Daylight Savings Time (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)


Can alter to accept Matlab time as input as follows,

if ~isstr(timeIn)
Date = datestr(timeIn, 'mm/DD/YYYY');
Date = timeIn;

Mark Morehead

This only works for 2007 and onward. The date definition changed in 2007 by President Bush Jr. It would be helpful if this allowed for input of a vector of Matlab's "datenums" instead of a text string.

Jeff Mather

Pretty much does exactly what you would want it to do.

Moeti Ncube


Hey Moeti,

This is because these dates are during USA daylight savings time. The 2011 switch occured 11/06/2011, and therefore

is_Daylight_Savings('11/06/2011') = 0 (false)
is_Daylight_Savings('10/31/2011') = 1

so there is no problem.

Moeti Ncube

Good idea, however something is not right...


All return 1's

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!