datetime default format by version and operating system

4 ビュー (過去 30 日間)
Rich006
Rich006 2023 年 5 月 10 日
コメント済み: Rich006 2023 年 5 月 10 日
On my Mac running R2022a, if I enter datetime('now') without specifying any format, I get 2023130090948. That is, it's 2023, the 130th day, at 9:09:48 AM. But on Windows running R2020b, the same input gives 10-May-2023 09:09:48. Is this difference due to the different operating systems, or different Matlab versions, or what? Where is the documentation?

採用された回答

Steven Lord
Steven Lord 2023 年 5 月 10 日
What are your datetime format preferences settings?
Can you confirm that you're using the datetime function included as part of MATLAB and not one that you downloaded?
which -all datetime
/MATLAB/toolbox/matlab/datatypes/datetime/@datetime/datetime.m % datetime constructor /MATLAB/toolbox/matlab/bigdata/@tall/datetime.m % tall method /MATLAB/toolbox/parallel/parallel/@codistributed/datetime.m % codistributed method
  1 件のコメント
Rich006
Rich006 2023 年 5 月 10 日
On my Mac:
which -all datetime
/Applications/MATLAB_R2022a.app/toolbox/finance/ftseries/@fints/private/datetime.m % Private to @fints
/Applications/MATLAB_R2022a.app/toolbox/matlab/bigdata/@tall/datetime.m % Shadowed tall method
/Applications/MATLAB_R2022a.app/toolbox/parallel/parallel/@codistributed/datetime.m % Shadowed codistributed method
/Applications/MATLAB_R2022a.app/toolbox/matlab/datatypes/datetime/@datetime/datetime.m % Shadowed datetime constructor
The Windows machine is on a server that I don't have access to at the moment. The same format difference shows up when I write to a text file with fprintf, which is what I'm trying to do. I didn't think changing the Command Window preference for datetime format would affected printing to file, but it did. Anyway, it's clear I should specify the format I want in my output file, rather than assuming the default format is always the same.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by