timediffposix¶
Purpose¶
Computes the difference between two dates in POSIX date/time format.
Format¶

diff =
timediffposix
(dt_1, dt_2, units)¶ Parameters:  dt_1 (NxK matrix) – containing 1 or more date/times in POSIX format.
 dt_2 (scalar) – the second date in POSIX format.
 units (string) –
indicating the units in which to report the difference.
Valid unit options:
 ”days”
 ”hours”
 ”minutes”
 ”seconds”
Returns: diff (Scalar) – the difference between dt_1 and dt_2 in terms of the specified units.
Examples¶
// Create dates from string for readability
dt_1 = strctoposix("February 14, 1979 19:30:21","%B %d, %Y %H:%M:%S");
dt_2 = strctoposix("February 14, 1979 14:30:21", "%B %d, %Y %H:%M:%S");
// Compute the difference in terms of hours
diff = timediffposix(dt_1, dt_2, "hours");
The above code will set diff equal to:
5
// Dates as seconds since Jan 1, 1970
dt_1 = 61446476430;
dt_2 = 61446477127;
// Calculate the difference
diff = timediffposix(dt_1, dt_2, "minutes");
The above code will set diff equal to:
11.617
// Dates as seconds since Jan 1, 1970
dt_1 = { 3490181, 3490101 };
dt_2 = 3490000;
// Find the time difference between the dates
diff = timediffposix(dt_1, dt_2, "seconds");
The above code will set diff equal to:
181
101
See also
Functions timeDiffDT()
, timeDeltaPosix()
, seqadt()
, seqaposix()