How to convert timestamp into Date-Time format in Erlang?

I am a beginner in Erlang programming. I have getting problem to convert timestamp format into Date-Time format. Can any one tell me how can I convert timestamp into Date-Time format?
I want to convert {Year, Month, Day} format. please help me.

Last updated:3/22/2016 1:08:16 AM

1 Answers

Tarun Kumar
Tarun Kumar

If you want to change timestamp format like {Year, Month, Day}, then you can use this example:
I hope it will solve your problem:

timestampToDate(Milliseconds) ->
  BDate = calendar:datetime_to_gregorian_seconds({{1995,1,1},{0,0,0}}),
  Sec = BDate + (Milliseconds div 1000),
  { Date,_Time} = calendar:gregorian_seconds_to_datetime(Sec),
   Date.

Answer