This language bar is your friend. Select your favorite languages!

Idiom #98 Epoch seconds to date object

Convert a timestamp ts (number of seconds in epoch-time) to a date with time d. E.g. 0 -> 1970-01-01 00:00:00

extern crate chrono;
use chrono::prelude::*:
let d = NaiveDateTime::from_timestamp(ts, 0);
import std.datetime, std.stdio;
auto d = SysTime(unixTimeToStdTime(ts), UTC());
var d = new DateTime.fromMillisecondsSinceEpoch(ts, isUtc: true);
Timestamp = {Seconds div 1000000, Seconds rem 1000000, 0},
calendar:now_to_universal_time(Timestamp).
import "time"
d := time.Unix(ts, 0)
import java.util.Date;
Date date = new Date(numberOfSecondsSinceEpoch  * 1000);
$d = DateTime::createFromFormat('U', $ts);
SysUtils
var
  D: TDateTime;
  TS: TTimeStamp;
begin
  D := TimeStampToDateTime(TS);
end.
import datetime
d = datetime.date.fromtimestamp(ts)
require 'date'
d = DateTime.strptime(ts, '%s')

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

elbrujohalcon