When I use "datetime" to convert seconds since an epoch (like unix time stamp, GPS time) I get on one PC the result shifted by 12 hours:
datetime(0,'convertfrom', 'epochtime','Epoch','1970-01-01 00:00:00')
ans =
datetime
1970-01-01 12:00:00.000
I only get this on one PC with 2018b, but not in 2016b. Also on another computer with 2018b I get what I expect:
ans =
datetime
1970-01-01 00:00:00.000
I am not sure what causes this shift. I do not think it can be related to time zones, it should only be +-1h.

댓글 수: 1

Steven Lord
Steven Lord 2023년 5월 25일
I agree with Cris's suspicion. I'd check that the default format is the same between the two machines. See the Preferences for the Command Window.

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

 채택된 답변

Cris LaPierre
Cris LaPierre 2023년 5월 25일
이동: Cris LaPierre 2023년 5월 25일

0 개 추천

Is it displaying in 24 hour format on one computer, and 12 hour format on another?
t = datetime(0,'convertfrom', 'epochtime','Epoch','1970-01-01 00:00:00')
t = datetime
01-Jan-1970
% display in 24 hr format
t.Format = 'dd-MMM-yyyy HH:mm:ss'
t = datetime
01-Jan-1970 00:00:00
% display in 12 hr format
t.Format = 'dd-MMM-yyyy hh:mm:ss'
t = datetime
01-Jan-1970 12:00:00

댓글 수: 2

Peter Perkins
Peter Perkins 2023년 6월 5일
Likely the datetime display format preference has been changed on the one machine.
Hans Wurst
Hans Wurst 2023년 6월 19일
You are right. I changed the default time format to include subseconds years ago, and used hh, not HH. Thanks!

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2018b

태그

질문:

2023년 5월 25일

댓글:

2023년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by