Convert string into date

2 views (last 30 days)
Happy PhD
Happy PhD on 30 Aug 2023
Commented: Star Strider on 30 Aug 2023
I am trying to convert "145601" into "14:56:01". How can I do this in a for loop?

Accepted Answer

Star Strider
Star Strider on 30 Aug 2023
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
Star Strider
Star Strider on 30 Aug 2023
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!