Dates and Time - MATLAB & Simulink (original) (raw)
Arrays of date and time values that can be displayed in different formats
The date and time data types datetime,duration, and calendarDuration support efficient computations, comparisons, and formatted display of dates and times. Work with these arrays in the same way that you work with numeric arrays. You can add, subtract, sort, compare, concatenate, and plot date and time values. You also can represent dates and times as numeric arrays or as text. For more information, see Represent Dates and Times in MATLAB or watch Date and Time Arrays.
(Not recommended; use datetime) Excel serial date number to MATLAB serial date number or datetime value
Times in MATLAB
Topics
Represent Dates and Times in MATLAB Use datetime arrays to store date and time information. These arrays support arithmetic, sorting, comparisons, plotting, and formatted display.
Replace Discouraged Instances of Serial Date Numbers and Date Strings As of R2022b, serial date numbers and date strings are not recommended for specifying dates and times. Use the datetime,duration, and calendarDuration data types instead. Follow these recommendations for updating your code.
Compare Dates and Time Compare dates, times, and durations by using relational operators, such as>, <, and ==, taking time zones and daylight saving time into account.
Set Date and Time Display Format The Format property on datetime, duration, and calendarDuration arrays controls the display of values in each array. You can change the value of this property. Changing the Format property does not change the values in the array, only their display.
Specify Time Zones Specify time zones for datetime arrays to account for time zone offsets, daylight saving time, or leap seconds.
Share Code and Data Across Locales Follow these best practices when sharing code that handles dates and time with MATLABĀ® users in other locales. Write and read dates from other locales.