Convert datetime that's not in Matlab format to a matlab format datetime
조회 수: 11 (최근 30일)
이전 댓글 표시
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
채택된 답변
dpb
2019년 5월 2일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!