etime — Find elapsed seconds between date vectors.
etime(t2,t1) converts three- or six-component date-vector rows to serial dates and returns (t2-t1)*86400 seconds. A single date-vector row expands over the rows of the other input; non-scalar row counts must match.
Syntax
seconds = etime(t2,t1)Inputs
DateVector- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- One date per row, with three or six numeric components.
Returns
out- Type
NumericArray- Description
- Host double result.
Precision and shapes
The output is host double. Seconds are calculated from RunMat's floating serial-day representation; small intervals at large date magnitudes can therefore lose subsecond precision. This function accepts date vectors, not arbitrary datetime objects or timezone-aware instants.
Execution and placement
The current date implementation evaluates these operations on the host. Resident numeric input is a RunMat extension and is rejected in MATLAB mode before provider access. In RunMat mode it is gathered through its provider owner; no date GPU kernel or fused operation is used. A provider gather can suspend or fail. The returned numeric, logical, or character value is host-resident.
These functions do not read files, access the network, call user callbacks, or mutate workspace state. The relative text values now, today, tomorrow, and yesterday read the local clock; datenum() also reads it. Results from those forms depend on the machine's local time setting.
Example
Elapsed seconds over one day
dt = etime([2024 1 2 0 0 0], [2024 1 1 0 0 0]);Expected output:
86400Using etime with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how etime changes the result.
Run a small etime example, explain the result, then change one input and compare the output.
FAQ
What is the unit?⌄
Seconds, including a fractional part when the represented date vectors permit it.
Related Datetime functions
Calendar Duration
caldays · calendarDuration · calendarDuration.eq · calendarDuration.minus · calendarDuration.ne · calendarDuration.plus · calmonths · calquarters · calweeks · calyears · datetick · iscalendarduration · isdatetime
Datetime
Construction
Operators
datetime.eq · datetime.ge · datetime.gt · datetime.le · datetime.lt · datetime.minus · datetime.ne · datetime.plus
Indexing
Duration
days · duration · duration.eq · duration.ge · duration.gt · duration.le · duration.lt · duration.minus · duration.ne · duration.plus · duration.subsasgn · duration.subsref · hours · isduration · milliseconds · minutes · seconds · years
Source you can read
Every RunMat function's source is public. Read exactly how etime is executed, line by line, in Rust.
- View the source for etime in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.