datetime and changing the month format

3 ビュー (過去 30 日間)
SKG
SKG 2019 年 2 月 2 日
編集済み: Walter Roberson 2019 年 2 月 2 日
Hey everyone,
I am trying to change the date input from csv file to another format that I want to use it for sorting.
The input of csv file:
Input=
'2019-01-25 17:00:17'
'2019-01-25 17:26:59'
'2019-01-25 17:39:31'
'2019-01-31 17:15:47'
-Output=datetime(Input,'InputFormat','yyyy-MM-dd HH:mm:ss');
Output:
'25-Jan-2019 17:00:17'
'25-Jan-2019 17:26:59'
'25-Jan-2019 17:39:31'
'31-Jan-2019 17:15:47'
However, I want the output 01-25-2019 HH:mm:ss
What is the best way to do that?

採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 2 日
編集済み: Walter Roberson 2019 年 2 月 2 日
Output = atetime(Input, 'InputFormat', 'yyyy-MM-dd HH:mm:ss', 'Format', 'MM-dd-yyyy HH:mm:ss')
Caution: using month day year rather than day month year does lead to international confusion.
Last time I did my taxes, I had a heck of a time figuring out the strange timings on some of my receipts until I realized that every once in a while they accidentally switched to m/d/y instead of d/m/y .

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by