필터 지우기
필터 지우기

from posix to date

조회 수: 116 (최근 30일)
Valeria Leto
Valeria Leto 2020년 3월 4일
댓글: Valeria Leto 2020년 3월 7일
Hi,
I am trying to use this command to convert the time vector t_ne expressed in posix time to a date
d = datetime(t_ne, 'ConvertFrom', 'posixtime')
but I get
datetime
5.0152e+10 CE
where is the problem?
  댓글 수: 2
Guillaume
Guillaume 2020년 3월 4일
"where is the problem?"
Your input is not a posix time, most likely. What is the value of t_ne?
Valeria Leto
Valeria Leto 2020년 3월 4일
it's 1582650648869329937

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 4일
This is a bit tricky because you are working past double precision accuracy.
t_ne = uint64(1582650648869329937);
NS = 1e9;
right_over = mod(t_ne, NS);
left_over = t_ne - right_over;
d = datetime( double(left_over)/NS, 'convertfrom', 'posixtime', 'Format', 'dd-MMM-uuuu HH:mm:ss.SSSSSSSSS') + seconds(double(right_over)/NS)
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 5일
Yup, the complications are to preserve the 17 nanoseconds.
Valeria Leto
Valeria Leto 2020년 3월 7일
thanks a lot! very kind :)

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

추가 답변 (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