Format for dates and times, specified as 'auto'
, a character vector, or a
string. The default format is based on the data.
Example: ztickformat('yyyy-MM-dd')
displays
a date and time such as 2016-04-19
.
Example: ztickformat('eeee, MMMM d, yyyy HH:mm:ss')
displays
a date and time such as Saturday, April 19, 2016 21:41:06
.
Example: ztickformat('MMMM d, yyyy HH:mm:ss Z')
displays
a date and time such as April 19, 2016 21:41:06 -0400
.
The display format tables show the letter identifiers that you can use to construct the
format. To separate the fields, you can include nonletter characters such as
a hyphen, space, colon, or any non-ASCII characters. The identifiers
correspond to the Unicode® Locale Data Markup Language (LDML) standard for dates.
Date and Time Formats
Use these identifiers to specify the display formats of the
date and time fields.
Letter Identifier | Description | Display |
---|
G | Era | CE |
y | Year, with no leading zeros. See the Note that follows this
table. | 2014 |
yy | Year, using last two digits. See the Note that follows this
table. | 14 |
yyy , yyyy ... | Year, using at least the number of digits specified by the
number of instances of 'y' | For the year 2014, 'yyy' displays 2014 ,
while 'yyyyy' displays 02014 . |
u , uu , ... | ISO year. A single number designating the year. An ISO year
value assigns positive values to CE years and negative values to BCE
years, with 1 BCE being year 0. | 2014 |
Q | Quarter, using one digit | 2 |
QQ | Quarter, using two digits | 02 |
QQQ | Quarter, abbreviated | Q2 |
QQQQ | Quarter, full name | 2nd quarter |
M | Month, numerical using one or two digits | 4 |
MM | Month, numerical using two digits | 04 |
MMM | Month, abbreviated name | Apr |
MMMM | Month, full name | April |
MMMMM | Month, capitalized first letter | A |
W | Week of the month | 1 |
d | Day of the month, using one or two digits | 5 |
dd | Day of the month using two digits | 05 |
D | Day of the year, using one, two or three digits | 95 |
DD | Day of the year using two digits | 95 |
DDD | Day of the year using three digits | 095 |
e | Day of the week, numerical using one or two digits. | 7 , where Sunday is the first day of the
week. |
ee | Day of the week, numerical using two digits | 07 |
eee | Day, abbreviated name | Sat |
eeee | Day, full name | Saturday |
eeeee | Day, capitalized first letter | S |
a | Day period (AM or PM) | PM |
h | Hour, 12-hour clock notation using one or two digits | 9 |
hh | Hour, 12-hour clock notation using two digits | 09 |
H | Hour, 24-hour clock notation using one or two digits | 21 |
HH | Hour, 24-hour clock notation using two digits | 21 |
m | Minute, using one or two digits | 41 |
mm | Minute, using two digits | 41 |
s | Second, using one or two digits | 6 |
ss | Second, using two digits | 06 |
S , SS , ..., SSSSSSSSS | Fractional second, using the number of digits specified by
the number of instances of 'S' (up to 9 digits). | 'SSS' truncates 6.12345 seconds to 123 . |
Some tips and considerations:
Use one or more u
characters instead
of y
characters to represent the year when working
with year numbers near zero.
Datetime values later than 144683 years CE or before
140743 BCE display only the year numbers, regardless of the specified
format value.
Time Zone Offset Formats
Use these identifiers to specify the display format of the time
zone offset. A time zone offset is the amount of time that a specific
date and time is offset from UTC. A time zone offset is different
from a time zone in that it comprises rules that determine the offsets
for specific times of the year. Include a time zone offset identifier
when you want to ensure that the time components are displayed unambiguously.
Letter Identifier | Description | Display |
---|
z | Abbreviated name of the time zone offset. If this value is
not available, then the time zone offset uses the short UTC format,
such as UTC-4 . | EDT |
Z | ISO 8601 basic format with hours, minutes, and optional seconds
fields. | -0400 |
ZZZZ | Long UTC format. | UTC-04:00 |
ZZZZZ | ISO 8601 extended format with hours, minutes, and optional
seconds fields. A time offset of zero is displayed as the ISO 8601
UTC indicator “Z”. | -04:00 |
x or X | ISO 8601 basic format with hours field and optional minutes
field. If you specify X , a time offset of zero
is displayed as the ISO 8601 UTC indicator “Z”. | -04 |
xx or XX | ISO 8601 basic format with hours and minutes fields. If you
specify XX , a time offset of zero is displayed
as the ISO 8601 UTC indicator “Z”. | -0400 |
xxx or XXX | ISO 8601 extended format with hours and minutes fields. If
you specify XXX , a time offset of zero is displayed
as the ISO 8601 UTC indicator “Z”. | -04:00 |
xxxx or XXXX | ISO 8601 basic format with hours, minutes, and optional seconds
fields. If you specify XXXX , a time offset of zero
is displayed as the ISO 8601 UTC indicator “Z”. | -0400 |
xxxxx or XXXXX | ISO 8601 extended format with hours, minutes, and optional
seconds fields. If you specify XXXXX , a time offset
of zero is displayed as the ISO 8601 UTC indicator “Z”. | -04:00 |