Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

clock

Current date and time as date vector

Syntax

Description

example

c = clock returns a six-element date vector containing the current date and time in decimal form:

[year month day hour minute seconds]

Examples

expand all

Round clock Output to Integer Display

Use clock to return the current date and time.

format shortg
c = clock
c =

         2014            1           17           10           46       57.788

The sixth element of the date vector output (seconds) is accurate to several digits beyond the decimal point.

Use the fix function to round to integer display format.

fix(c)
ans =

        2014           1          17          10          46          57

More About

expand all

Tips

  • To time the duration of an event, use the timeit or tic and toc functions instead of clock and etime. 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.

See Also

| | | | | | |

Was this topic helpful?