필터 지우기
필터 지우기

How to change datetime format?

조회 수: 123 (최근 30일)
Sim
Sim 2023년 6월 13일
댓글: Sim 2023년 6월 13일
Given this:
datetime('02-Jul-2023','InputFormat','dd-MMM-yyyy')
ans = datetime
02-Jul-2023
How can I get this format ?
datetime('02-Jul-2023 22:00:00')
ans = datetime
02-Jul-2023 22:00:00

채택된 답변

Stephen23
Stephen23 2023년 6월 13일
편집: Stephen23 2023년 6월 13일
You can specify different formats for the input and display:
DT = datetime('02-Jul-2023','InputFormat','dd-MMM-yyyy', 'Format','dd-MMM-yyyy HH:mm:ss')
DT = datetime
02-Jul-2023 00:00:00
If it is an existing DATETIME object, then simply modify its FORMAT property as you wish, e.g.:
DT.Format = 'uuuuDDD' % ISO 8601 day-number format
DT = datetime
2023183
  댓글 수: 1
Sim
Sim 2023년 6월 13일
Great @Stephen23!!!! Thanks a lot !! :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by