Home > DeveloperSection > Forums > How to convert timestamp into Date-Time format in Erlang?
Monaj Singh
Monaj Singh

Total Post:41

Points:287
Posted on    March-22-2016 12:21 AM

 erlang erlang 
Ratings:


 1 Reply(s)
 296  View(s)
Rate this:

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.



Tarun Kumar

Total Post:213

Points:1635
Supported
Posted on    March-22-2016 1:08 AM

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.

Modified On Mar-28-2016 12:35:46 AM

Don't want to miss updates? Please click the below button!

Follow MindStick