HOW TO CONVERT TIMESTAMP INTO DATE-TIME FORMAT IN ERLANG?

Monaj Singh

Total Post:41

Points:287
Posted by  Monaj Singh
erlang 
 741  View(s)
Ratings:
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.

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to convert timestamp into Date-Time format in Erlang?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!