Documentation

etime

Time elapsed between date vectors

Syntax

e = etime(t2,t1)

Description

example

e = etime(t2,t1)returns the number of seconds between two date vectors or matrices of date vectors,t1andt2.

Examples

collapse all

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.

formatshortgstr ='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 = 2017 9 19 18 53 43.346

Theclockfunction returns the current date and time as a date vector.

Useetimeto compute the number of seconds betweent1andt2.

e = etime(t2,t1)
e = 1.7291e+08

Input Arguments

collapse all

Date vectors, specified as 1-by-6 vectors orm-by-6 matrices containingmfull date vectors in the format:[Year Month Day Hour Minute Second].

Example:[2012 03 27 11 50 01]

Data Types:double

Tips

  • To time the duration of an event, use thetimeitorticandtocfunctions instead ofclockandetime. Theclockfunction 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.

Algorithms

etimedoes not account for the following:

  • Leap seconds.

  • Daylight savings time adjustments.

  • Differences in time zones.

Introduced before R2006a

Was this topic helpful?