How do I round a 'datetime' to the nearest second?
显示 更早的评论
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?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!