Character to date and time

1 回表示 (過去 30 日間)
Vengatesan
Vengatesan 2012 年 8 月 15 日
I have a series of date & time data as below
'2012-03-01T00:01:00.000Z'
'2012-03-01T00:30:59.999Z'
'2012-03-01T01:00:59.999Z'
'2012-03-01T01:31:00.000Z'
'2012-03-01T02:00:59.999Z'
'2012-03-01T02:29:59.999Z'
'2012-03-01T03:00:00.000Z'
I would like to remove 'T' and 'Z' and re-write the above into another date/time series of a form (please note a space between date and time):
01/03/2012 00:01:00.000
01/03/2012 00:30:59.999
01/03/2012 01:00:59.999
01/03/2012 01:31:00.000
01/03/2012 02:00:59.000
01/03/2012 02:29:59.999
01/03/2012 03:00:00.000
Any help Thanks.

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 8 月 15 日
A = { '2012-03-01T00:01:00.000Z'
'2012-03-01T00:30:59.999Z'
'2012-03-01T01:00:59.999Z'
'2012-03-01T01:31:00.000Z'
'2012-03-01T02:00:59.999Z'
'2012-03-01T02:29:59.999Z'
'2012-03-01T03:00:00.000Z'}
out = regexprep(A,{'T','Z$'},{' ',''});
  3 件のコメント
Vengatesan
Vengatesan 2012 年 8 月 15 日
Andrei, Just one more point. I would like to write the date/time as
01/03/2012 00:01:00.000 01/03/2012 00:30:59.999 01/03/2012 01:00:59.999 01/03/2012 01:31:00.000 01/03/2012 02:00:59.000 01/03/2012 02:29:59.999 01/03/2012 03:00:00.000
but your solution gives '2012-03-01 00:01:00.000' '2012-03-01 00:30:59.999' '2012-03-01 01:00:59.999' '2012-03-01 01:31:00.000' '2012-03-01 02:00:59.999' '2012-03-01 02:29:59.999' '2012-03-01 03:00:00.000' Thanks.
Andrei Bobrov
Andrei Bobrov 2012 年 8 月 15 日
A = {'01/03/2012 00:01:00.000'
'01/03/2012 00:30:59.999'
'01/03/2012 01:00:59.999'
'01/03/2012 01:31:00.000'
'01/03/2012 02:00:59.000'
'01/03/2012 02:29:59.999'
'01/03/2012 03:00:00.000'};
out = cellstr(datestr(datenum(A,'dd/mm/yyyy HH:MM:SS.FFF'),'yyyy-mm-dd HH:MM:SS.FFF'));

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

その他の回答 (0 件)

カテゴリ

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