Share Code and Data Across Locales
In this section...
“Write Locale-Independent Date and Time Code” on page 7-25
“Write Dates in Other Languages” on page 7-26
“Read Dates in Other Languages” on page 7-27
Write Locale-Independent Date and Time Code
Follow these best practices when sharing code that handles dates and time with
MATLAB® users in other locales. These practices ensure that the same code produces the
same output display and that output files containing dates and time are read correctly on
systems in different countries or with different language settings.
Create language-independent datetime values. That is, create datetime values that use
month numbers rather than month names, such as 01 instead of January. Avoid using day
of week names.
For example, do this:
t = datetime('today','Format','yyyy-MM-dd')
t = datetime
2019-04-13
instead of this:
t = datetime('today','Format','eeee, dd-MMM-yyyy')
t = datetime
Saturday, 13-Apr-2019
Display the hour using 24-hour clock notation rather than 12-hour clock notation. Use the
'HH' identifiers when specifying the display format for datetime values.
For example, do this:
t = datetime('now','Format','HH:mm')
Share Code and Data Across Locales