Convert datetime to string

조회 수: 428 (최근 30일)
Ali razi
Ali razi 2022년 10월 12일
답변: Adam Danz 2022년 10월 12일
How can I convert
datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss')
to a string with this structure: 12-Oct-2022_18:12:17

채택된 답변

Adam Danz
Adam Danz 2022년 10월 12일
Use string after formatting your datetime.
dt = datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss')
dt = datetime
12-Oct-2022 18:30:14
dtstr = string(dt)
dtstr = "12-Oct-2022 18:30:14"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by