How do I round a 'datetime' to the nearest second?
Show older comments
I have the following date and time:
2023-11-07 23:47:43.605
I can construct a 'datetime' for this as such:
>> d = '2023-11-07 23:47:43.605';
>> t = datetime(d,'InputFormat','yyyy-MM-dd HH:mm:ss.SSS')
t =
datetime
07-Nov-2023 23:47:43
I would like to round this to the nearest second to receive the following output after displaying:
2023-11-07 23:47:44
How do I do this?
Accepted Answer
More Answers (0)
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!