How to change the date format by not misplacing days with months?

2 ビュー (過去 30 日間)
B.kun
B.kun 2014 年 6 月 22 日
コメント済み: Star Strider 2014 年 6 月 22 日
Dear all,
I have a huge dataset with dates in the first column of the array (lets call it 'myarray'). My date in the first column of "myarray" is displayed as follows: '1-12-13 21:34' '1-12-13 21:35' '1-12-13 21:36' However, I want to change the format of my dates to two-digits days, i.e. 'dd-mm-yy HH:MM'.
But when I executed this code: myarray= cellstr(datestr(myarray(:,1),'dd-mm-yy HH:MM'));
The dates became: '12-01-13 21:34' '12-01-13 21:35' '12-01-13 21:36'
My original date is 1st of December, but the dates became 12th January... Can anyone help me make them the correct date? with format dd-mm-yy.
Thank you very much!

採用された回答

Star Strider
Star Strider 2014 年 6 月 22 日
編集済み: Star Strider 2014 年 6 月 22 日
See if this does what you want:
DateTime = {'1-12-13 21:34' '1-12-13 21:35' '1-12-13 21:36'};
NewDate = datestr(datenum(DateTime, 'dd-mm-yy HH:MM'), 'dd-mm-yy HH:MM')
produces:
NewDate =
01-12-13 21:34
01-12-13 21:35
01-12-13 21:36
  2 件のコメント
B.kun
B.kun 2014 年 6 月 22 日
Oh yes, it worked now! Thank you so much!!
Star Strider
Star Strider 2014 年 6 月 22 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by