MATLAB Answers

Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#">여기</a>"를 클릭하십시오.

0

Convert datetime that's not in Matlab format to a matlab format datetime

Asked by Rahah Hadri on 2 May 2019
Latest activity Commented on by Rahah Hadri on 4 May 2019
Accepted Answer by dpb
Hi, I have a cell array of datetime in a different format that isn't recognised in Matlab's format. Eg : 2014-12-13T18:45:00+00:00 . How do I change this to an acceptable Matlab datetime format ? Like 'yyyy-MM-dd''T''HH:mmXXX'?

  0 Comments

Sign in to comment.

1 Answers

Answer by dpb
on 2 May 2019
 Accepted Answer

TZ offsets are recognized in ML datetime -- your string can be converted as:
s='2014-12-13T18:45:00+00:00';
>> datetime(s,'InputFormat','yyyy-MM-dd''T''HH:mm:ssxxx', ...
'TimeZone','Europe/London', ...
'Format','yyyy-MM-dd HH:mm:ss')
ans =
datetime
2014-12-13 18:45:00
>>
You do have to provide the reference 'TimeZone' named parameter to convert the input date string in a specific time zone; however; once done, if wanted can convert to unzoned time by setting resultant variable 'TimeZone' property to the empty/null string '';
I chose a different display format simply to illustrate...set as desired.

  1 Comments

Sign in to comment.



Translated by