how to convert timestamps to number of seconds
조회 수: 43 (최근 30일)
이전 댓글 표시
Hi, I have a data that has a column of timestamps as seen below, how can I convert the timestamps to number of seconds? '2013-01-01 00:00:00' '2013-01-01 00:00:01' '2013-01-01 00:00:02' I get some large number like735235 735235.000011574 735235.000023148 735235.000034722 when I used datenum(), are I guess these numbers are just the format in which the date and time are stored. How do get the time in seconds?
댓글 수: 0
채택된 답변
Stephen23
2016년 4월 29일
편집: Stephen23
2016년 4월 29일
What do you mean by "number of seconds" ? The number of seconds from when? From what epoch? (without an epoch it is meaningless to count seconds).
The definition of MATLAB's serial date number is clearly defined: "the number of days from January 0, 0000". If you want this time in seconds then simply multiply the serial date number by the number of seconds in a day. Note that these numbers will be much larger!
If you only need the seconds component of those timestamps, then use datevec, and take a look at the sixth column of data:
>> C = {'2013-01-01 00:00:00' '2013-01-01 00:00:01' '2013-01-01 00:00:02'};
>> V = datevec(C)
V =
2013 1 1 0 0 0
2013 1 1 0 0 1
2013 1 1 0 0 2
>> V(:,6)
ans =
0
1
2
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!