convert period (.) to colon (:) for reading time

조회 수: 7 (최근 30일)
Andrew Green
Andrew Green 2020년 7월 29일
댓글: Steven Lord 2020년 7월 29일
Hi,
I have imported some data that includes a time stamp but the way it writes it's date and time is "yyy-MM-dd HH.mm.ss"
Is there any way to convert the period (.) to a colon (:) so that matLab reads the time better?
Cheers,
Andy
  댓글 수: 1
KSSV
KSSV 2020년 7월 29일
You have many functions to read that format...you need not to change it..read about datestr, datetime, datenum, datevec.

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

답변 (1개)

Stephen23
Stephen23 2020년 7월 29일
I don't see why you need to convert any characters, MATLAB imports that format without error:
>> str = '2020-07-29 14.42.32';
>> dtm = datetime(str,'InputFormat','yyyy-MM-dd HH.mm.ss')
dtm =
29-Jul-2020 14:42:32
  댓글 수: 1
Steven Lord
Steven Lord 2020년 7월 29일
You can get MATLAB to show the resulting datetime in that form as well if you want.
str = '2020-07-29 14.42.32';
F = 'yyyy-MM-dd HH.mm.ss';
dtm = datetime(str, 'InputFormat', F, 'Format', F)

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

카테고리

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