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!