Character Unit Required?
q Quarters (multiples of
3 months)
no
m Months yes
w Weeks no
d Days yes
t Time (hours, minutes,
and seconds)
yes
To specify the number of digits displayed for fractional seconds, use the format function.
If the value of a date or time component is zero, it is not displayed.
Changing the Format property does not change the values in the array, only their display.
Default datetime Format
You can set default formats to control the display of datetime arrays created without an
explicit display format. These formats also apply when you set the Format property of a
datetime array to 'default' or 'defaultdate'. When you change the default
setting, datetime arrays set to use the default formats are displayed automatically using
the new setting.
Changes to the default formats persist across MATLAB sessions.
To specify a default format, type
datetime.setDefaultFormats('default',fmt)
where fmt is a character vector composed of the letters A-Z and a-z described for the
Format property of datetime arrays, above. For example,
datetime.setDefaultFormats('default','yyyy-MM-dd hh:mm:ss')
sets the default datetime format to include a 4-digit year, 2-digit month number, 2-digit
day number, and hour, minute, and second values.
In addition, you can specify a default format for datetimes created without time
components. For example,
datetime.setDefaultFormats('defaultdate','yyyy-MM-dd')
Set Date and Time Display Format