Time elapsed between date vectors
e = etime(t2,t1)example
Compute the time elapsed between a specific time and the current time, to 0.01-second accuracy.
Define the initial date and time and convert to date vector form.
format shortg str = 'March 28, 2012 11:51:00'; t1 = datevec(str,'mmmm dd, yyyy HH:MM:SS')
t1 = 2012 3 28 11 51 0
Determine the current date and time.
t2 = clock
t2 = 2015 2 23 9 46 35.048
clock function returns the current date and time as a date vector.
etime to compute the number of seconds between
e = etime(t2,t1)
e = 9.1749e+07
To time the duration of an event, use the
clock function is based on the system time,
which can be adjusted periodically by the operating system, and thus
might not be reliable in time comparison operations.
etime does not account for the following:
Daylight savings time adjustments.
Differences in time zones.