How Do I Have my Program Accept a Negative Year as Valid

I am creating a time calculator game to learn how to code and am running into trouble when I input a negative year. How can I program a time calculator that recognizes this negative year as BCE while not displaying an invalid message? I

답변 (1개)

Alexander
Alexander 2024년 2월 16일

0 개 추천

datetime(-1,1,1) answeres 01-Jan--0001 which is correct.

댓글 수: 2

Thank you, how would I do this for the MM/DD/YYYY format where the user enteres their date like this?
datetime('01/01/-0001', 'inputformat', 'MM/dd/uuuu')
ans = datetime
01-Jan--0001

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

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

태그

질문:

2024년 2월 16일

댓글:

2024년 2월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by