convert date to number

조회 수: 4 (최근 30일)
Mathis Faure
Mathis Faure 2020년 3월 15일
편집: Star Strider 2020년 3월 15일
Hi,
I want to convert this : 00:01:36.480
HH:MM:SS.fff where f is a millisecond
into this number 000136480
is it possible?
my version of matlab R2019b
thank you
  댓글 수: 3
Mathis Faure
Mathis Faure 2020년 3월 15일
it's a date forma I think, and I want to convert it into an integer.
Mathis Faure
Mathis Faure 2020년 3월 15일
I think that is a character aray

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

답변 (1개)

Star Strider
Star Strider 2020년 3월 15일
편집: Star Strider 2020년 3월 15일
This appears to do what you want:
This = '00:01:36.480';
NowThis = datetime(This, 'InputFormat','HH:mm:ss.SSS', 'Format','HHmmssSSS')
producing:
NowThis =
datetime
000136480
EDIT — (15 Mar 2020 at 14:51)
To get a character array output:
This = '00:01:36.480';
NowThis = string(datetime(This, 'InputFormat','HH:mm:ss.SSS', 'Format','HHmmssSSS'))
ThisStr = sscanf(NowThis, '%s')
producing:
ThisStr =
'000136480'

카테고리

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