Convert string into date

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

 Accepted Answer

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

2 Comments

Thanks.
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022b

Tags

Community Treasure Hunt

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

Start Hunting!