Function: time-subtract

time-subtract is a function defined in timefns.c.

Signature

(time-subtract A B)

Documentation

Return the difference between two time values A and B, as a time value.

You can use float-time to convert the difference into elapsed seconds. See format-time-string for the various forms of a time value. For example, nil stands for the current time.

View in manual

Probably introduced at or before Emacs version 25.1.

Aliases

subtract-time (obsolete since 26.1) org-time-subtract (obsolete since 9.6)

Source Code

// Defined in /usr/src/emacs/src/timefns.c
{
  /* Subtract nil from nil correctly, and handle other eq values
     quicker while we're at it.  This means (time-subtract X X) does
     not signal an error if X is not a valid time value, but that's OK.  */
  if (BASE_EQ (a, b))
    return make_lisp_time ((struct timespec) {0});

  return time_arith (a, b, true);
}