フィルターのクリア

extract seconds from timestamp in cell

1 回表示 (過去 30 日間)
Tiffany Lee
Tiffany Lee 2012 年 10 月 24 日
In cell column 1 I have this timestamp. 2011-04-19T01:01:59.000Z I want to put in column 2 the time in seconds. So this is 1 hour, 1 minute and 59 seconds so I want column 2 to be 3719 seconds.
How do I deal with only extracting the time?

回答 (2 件)

Kye Taylor
Kye Taylor 2012 年 10 月 24 日
編集済み: Kye Taylor 2012 年 10 月 24 日
I assume that the timestamp is represented as a string like:
C{1} = '2011-04-19T01:01:59.000Z';
Then, try
timeStamp = regexp(C{1},'\d*:\d*:\d*','match');
v = datevec(timeStamp);
C{2} = v(end-2:end)*[3600;60;1];
  1 件のコメント
Tiffany Lee
Tiffany Lee 2012 年 11 月 14 日
thanks!

サインインしてコメントする。


Matt Fig
Matt Fig 2012 年 10 月 24 日
Say your cell array looks like:
T = {'2011-04-19T01:01:59.000Z';...
'2011-05-19T01:21:02.000Z';...
'2011-06-19T21:11:51.000Z'}
% Now fill second column with seconds
STR = '${num2str(str2num($2)*3600+str2num($3)*60+str2num($4))}';
T(:,2) = regexprep(T,'(.*T)(\d+):(\d+):(\d+)(.*)',STR)
  1 件のコメント
Tiffany Lee
Tiffany Lee 2012 年 11 月 14 日
thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by