Convert string into date

I am trying to convert "145601" into "14:56:01". How can I do this in a for loop?

 采纳的回答

No loop needed. Just use datetime
str = "145601"
str = "145601"
DT = datetime(str, 'InputFormat',"HHmmss", 'Format','HH:mm:ss')
DT = datetime
14:56:01
.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Dates and Time 的更多信息

产品

版本

R2022b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by