Cell Dates to Timestamp conversion

조회 수: 10 (최근 30일)
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 6월 24일
댓글: Emmanouil Barmpounakis 2015년 6월 24일
I have a 3480x2 cell. The first column shows the date (6/24/2015) and the second one shows the hour (8:33:49). How can I create a new array where the first column will appear as a UNIX timestamp?
For example, C(1,1)=1435134829 (which is equal to 6/24/2015 - 8:33:49).

채택된 답변

Peter Perkins
Peter Perkins 2015년 6월 24일
In MATLAB R2014b or later, using datetime:
>> c = {'6/24/2015' '8:33:49'; '6/24/2015' '8:33:48'}
c =
'6/24/2015' '8:33:49'
'6/24/2015' '8:33:48'
>> d = datetime(strcat(c(:,1),{' '},c(:,2)))
d =
24-Jun-2015 08:33:49
24-Jun-2015 08:33:48
>> format long g
>> posixtime(d)
ans =
1435134829
1435134828
Hope this helps.
  댓글 수: 1
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 6월 24일
Thank you for your reply. It works perfectly .

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

추가 답변 (0개)

카테고리

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