FreeMat

- Main Page
- Related Pages

CLOCKTOTIME Convert Clock Vector to Epoch Time

Section: FreeMat Functions

# Usage

Given the output of the `clock` command, this function computes the epoch time, i.e, the time in seconds since January 1,1970 at 00:00:00 UTC. This function is most useful for calculating elapsed times using the clock, and should be accurate to less than a millisecond (although the true accuracy depends on accuracy of the argument vector). The usage for `clocktotime` is

       y = clocktotime(x)

where `x` must be in the form of the output of `clock`, that is

       x = [year month day hour minute seconds]

# Example

Here is an example of using `clocktotime` to time a delay of 1 second

    --> x = clock

    x =

       1.0e+03 *
        2.0120    0.0020    0.0080    0.0220    0.0420    0.0415

    --> sleep(1)
    --> y = clock

    y =

       1.0e+03 *
        2.0120    0.0020    0.0080    0.0220    0.0420    0.0425

    --> clocktotime(y) - clocktotime(x)

    ans =
        1.0010