필터 지우기
필터 지우기

How to convert timestamp string to datetime object in matlab

조회 수: 189 (최근 30일)
Maryam BODAGHI
Maryam BODAGHI 2021년 7월 1일
댓글: Maryam BODAGHI 2021년 7월 1일
Hi every body
I have an excel file, one column is date and time in this firmat:(the file is datas of power in each about 3 seconds)
1303133628.00000
1303133632.00000
1303133635.00000
1303133639.00000
1303133642.00000
how can I convert it to date time in format like:
2011-04-18 21:22:13
thanks

채택된 답변

Rik
Rik 2021년 7월 1일
UTC_epoch_seconds=1303133628;
UTC_offset=UTC_epoch_seconds/(24*60*60);
atomTime=UTC_offset+datenum(1970,1,1);
datetime(atomTime,'ConvertFrom','datenum')
ans = datetime
18-Apr-2011 13:33:48

추가 답변 (1개)

Smitesh Patil
Smitesh Patil 2021년 7월 1일
If the data is stored in array 'x' then you can pass it to datatime in the following manner
d = datetime(x,'ConvertFrom','posixtime', 'Format', 'yyyy-MM-dd HH:mm:ss')

카테고리

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