Is it possible to subtract one DateTime from another and get the result in Time.
Example if we subtract 2011-08-27 01:00:00 UTC from 2011-08-29 08:13:00 UTC, the result should be 55:13:00 (hope I didn’t make a mistake while calulating :p)
Thanks.
Is it possible to subtract one DateTime from another and get the result in
Share
Time is generally expressed in seconds when doing math like this, even fractional seconds if you want. A
Timerepresents a specific point in time, which while internally represented as seconds since the January 1, 1970 epoch, is not intended to be a scalar unit like that.If you have two
DateTimeobjects, you can determine the difference between them like this:Once you have the number of seconds, the rest is simply a formatting problem: