Date and time formate translation

조회 수: 4 (최근 30일)
Martin
Martin 2018년 12월 1일
편집: Martin 2018년 12월 2일
I need to translate those dates and time (strings)
'25-Mar-2014 13:00:00'
'07-Nov-2018 18:30:45'
to the forllowing format (in string as well):
'2014-03-25T13:00:00.000Z'
'2018-11-07T18:30:45.000Z'
Any idea how to handle such kind of formats? I find it pretty complex...
  댓글 수: 2
madhan ravi
madhan ravi 2018년 12월 1일
what does T and Z represent just curious?
Martin
Martin 2018년 12월 1일
Actually I Dont Know!

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

채택된 답변

dpb
dpb 2018년 12월 1일
편집: dpb 2018년 12월 1일
dt=datetime('25-Mar-2014 13:00:00');
fmt= 'uuuu-MMM-dd''T''HH:mm:ss.SSS''Z';
dt.Format=fmt;
>> dt =
datetime
2014-Mar-25T13:00:00.000Z
>>
  댓글 수: 3
dpb
dpb 2018년 12월 1일
Yes. datestr is a remnant of the deprecated datenum that didn't have a formatting option; it is just a particularly-scaled double.
char(dt) is the idiom if need the character array; for most purposes however, either cellstr or string is probably more useful/less coding downstream--but depends upon just why you actually need the string representation at all...
Martin
Martin 2018년 12월 2일
편집: Martin 2018년 12월 2일
I need to get a response from a statistical data API on the internet. This API only takes this kind of format. Do you have any suggestion how to get posix time from the format? string: timestr='2014-03-25T13:00:00.000Z'?
EDIT: Okay figured out. First I use t= datetime(timestr,'Format','yyyy-MM-dd''T''HH:mm:ss.SSS''Z')
then just posixtime(t)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by