how can I add add sec, min and hours to time?
197 views (last 30 days)
Show older comments
I want to add sec, min and hours to a time.
Example:
now it is 07:00:00 am and i would like to add 320 sec to be 07:05:20 am
I try "datenum" but this include a date which I don't want ?
10 Comments
Walter Roberson
on 13 Nov 2017
dt = datetime( '23:58:00', 'InputFormat', 'HH:mm:ss' );
dt.Format = 'HH:mm:ss';
dt + seconds(320)
ans =
datetime
00:03:20
Answers (2)
KL
on 10 Nov 2017
Use duration maybe,
>> t1 = duration([07 0 0])
t1 =
duration
07:00:00
>> t2 = t1+seconds(320)
t2 =
duration
07:05:20
1 Comment
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!