MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
t2 =

Oct 01, 2014 Oct 02, 2014

t2 is also a datetime array.

whos t2

Name Size Bytes Class Attributes

t2 1x2 161 datetime

In summary, there are several ways to represent dates and times, and MATLAB has a data
type for each approach:


  • Represent a point in time, using the datetime data type.
    Example: Wednesday, June 18, 2014 10:00:00

  • Represent a length of time, or a duration in units of fixed length, using the duration
    data type. When using the duration data type, 1 day is always equal to 24 hours, and
    1 year is always equal to 365.2425 days.
    Example: 72 hours and 10 minutes

  • Represent a length of time, or a duration in units of variable length, using the
    calendarDuration data type.
    Example: 1 month, which can be 28, 29, 30, or 31 days long.
    The calendarDuration data type also accounts for daylight saving time changes and
    leap years, so that 1 day might be more or less than 24 hours, and 1 year can have 365
    or 366 days.


7 Dates and Time

Free download pdf