Get the time difference between two datetimes

I know I can do anything and some more envolving Dates with momentjs. But embarrassingly, I’m having a hard time trying to do something that seems simple: geting the difference between 2 times. Example: var now = “04/09/2013 15:00:00”; var then = “04/09/2013 14:20:30”; //expected result: “00:39:30” what I tried: var now = moment(“04/09/2013 15:00:00”); … Read more

In Python, how do you convert seconds since epoch to a `datetime` object?

The time module can be initialized using seconds since epoch: >>> import time >>> t1=time.gmtime(1284286794) >>> t1 time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19, tm_sec=54, tm_wday=6, tm_yday=255, tm_isdst=0) Is there an elegant way to initialize a datetime.datetime object in the same way? 5 Answers 5