clock
Current date and time as date vector
Syntax
c = clock
[c tf] = clock
Description
c = clock
returns a six-element date vector containing the current date and time in decimal form:
[year month day hour minute seconds]
Theclock
function calculates the current date and time from the system time.
[c tf] = clock
returns a second output argument that is1
(true
) if the current date and time occur during Daylight Saving Time (DST) in your system's time zone, and0
(false
) otherwise.
Examples
Tips
To time the duration of an event, use the
timeit
ortic
andtoc
functions instead ofclock
andetime
. Theclock
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.To return a datetime scalar representing the current date and time, type:
t = datetime('now')