How can I convert a datetime array from english to spanish format?

조회 수: 7 (최근 30일)
Adriano
Adriano 2022년 4월 7일
댓글: MJFcoNaN 2022년 4월 8일
Hi all,
I have this datetime array :
'27-Dec-2019'
'03-Jan-2020'
'10-Jan-2020'
'17-Jan-2020'
'24-Jan-2020'
'31-Jan-2020'
'07-Feb-2020'
'14-Feb-2020'
'21-Feb-2020'
I want to convert english months in spanish months. For example "Jan" will be "Ene" and "Dec" will be "Dic". Thus, I want a datetime array like below:
'27-Dic-2019'
'03-Ene-2020'
'10-Ene-2020'
'17-Ene-2020'
'24-Ene-2020'
'31-Ene-2020'
'07-Feb-2020'
'14-Feb-2020'
'21-Feb-2020'
How can I do it? Thanks to all!

답변 (1개)

MJFcoNaN
MJFcoNaN 2022년 4월 7일
The "Command Window Preferences" controls default locale and date settings.
However, if you only need output some strings, try this kind of code:
string(datetime(2020,12,2), "dd-MMM-yyyy", "es_ES")
  댓글 수: 2
Adriano
Adriano 2022년 4월 7일
It doesn't work because the output of your code is a string and not a datetime
MJFcoNaN
MJFcoNaN 2022년 4월 8일
The "Preferences----Command Window Preferences----Format of date and time" controls default locale and date settings.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by