Avoid datetime changes due to saving daylight
14 views (last 30 days)
Show older comments
Good morning,
I have a timeserie from a .xlsx file. I import dates as datetime variable. All data are collected as solar time.
D=readtable(fullfile(path,file),opt,"UseExcel",false); %import a matrix
D.Properties.VariableNames{1}='Date'; %the first column are dates and read as datetime
D.Date.Format='dd/MM/yyyy HH:mm';
D.Date.TimeZone='Europe/Rome';
Unfortunatly, on March, 25th 2007 there was the shift from solar time (maybe in english is more correct refers to this as 'winter time') to legal time (maybe 'saving daylight time'). MATLAB, shift hours as follow:
Input datetime (original) datetime shifted by matlab
24/03/2007 22:00 24/03/2007 22:00
24/03/2007 23:00 24/03/2007 23:00
25/03/2007 00:00 25/03/2007 00:00
25/03/2007 01:00 25/03/2007 01:00
25/03/2007 02:00 25/03/2007 03:00
25/03/2007 03:00 25/03/2007 03:00
25/03/2007 04:00 25/03/2007 04:00
25/03/2007 05:00 25/03/2007 05:00
How could I avoid it and keep the original datetime?
2 Comments
Walter Roberson
on 5 Jan 2021
The input entries you show on the left: What time UTC do each of them represent? What time local do you want them changed to?
Accepted Answer
Eric Sofen
on 5 Jan 2021
Do you need to use time zones in your app? In MATLAB, you can work with "unzoned" datetimes, where Daylight Saving Time doesn't show up at all.
More Answers (1)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!