문제

Erlang에서 Timestamp (1970 년 1 월 1 일 이후 밀리 초 수 ...)를 어떻게 변환 할 수 있습니까? {연도, 월, 일}과 같은 것.

도움이 되었습니까?

해결책

대충:

msToDate(Milliseconds) ->
   BaseDate      = calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}),
   Seconds       = BaseDate + (Milliseconds div 1000),
   { Date,_Time} = calendar:gregorian_seconds_to_datetime(Seconds),
   Date.

다른 팁

정확히이 목적을 위해 많은 DateTime 유틸리티가있는 Github gist가 있습니다. http://gist.github.com/104903. 캘린더는이 물건에 대한 대부분의 저수준 배관을 가지고 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top