The primary way to store date and time information is in
which support arithmetic, sorting, comparisons, plotting, and formatted
display. The results of arithmetic computations are returned in
or, when you use calendar-based functions, in
For more information, see Represent Dates and Times in MATLAB or
and Time Arrays.
||Create array based on current date, or convert from date strings or numbers|
||List time zones|
||Duration in years|
||Duration in days|
||Duration in hours|
||Duration in minutes|
||Duration in seconds|
||Duration in milliseconds|
||Create duration array from numeric values|
||Calendar duration in years|
||Calendar duration in quarters|
||Calendar duration in months|
||Calendar duration in weeks|
||Calendar duration in days|
||Create calendar duration array from numeric values|
|datetime Properties||Assign date and time components and specify datetime display format|
datetime arrays to store date
and time information. These arrays support arithmetic, sorting, comparisons,
plotting, and formatted display.
Format property on
calendarDuration arrays controls the display
of values in each array. You can change the value of this property.
Format property does not change the
values in the array, only their display.
When you create a datetime, it is unzoned by default. If you work with datetime values from multiple time zones or need to account for daylight saving time, you might need to specify a time zone.
You can convert datetime arrays to numeric formats that count seconds or days elapsed since the start time for a given format. When you convert a datetime array to POSIX times or Julian dates, the best practice is to specify the time zone before conversion.
Generate sequences of dates and times. Sequences include dates and times that are consecutive, equally spaced between two points, or that use calendar rules.
Follow these best practices when sharing code that handles dates and time with MATLAB® users in other locales. Write and read dates from other locals.