How do I read a text file and convert the dates and time?

조회 수: 8 (최근 30일)
Sonima
Sonima 2018년 7월 25일
편집: Sonima 2019년 8월 15일
Hi! I have a text file that includes the following:
2015-06-18 12:00

채택된 답변

jonas
jonas 2018년 7월 25일
편집: jonas 2018년 7월 25일
Your format string is wrong, try
datenum(tt,'yyyy-mm-dd HH:MM');
better yet, use datetime

추가 답변 (1개)

Peter Perkins
Peter Perkins 2018년 8월 3일
It's likely that you want to read the file using readtable, and if you are using a recent version of MATLAB, you will get datetimes automatically. If not, you can convert to datetime after importing.
You are better off using datetime than datenum.

카테고리

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