Current date and time as date vector
c = clock returns a six-element date vector containing the current date
and time in decimal form:
[year month day hour minute seconds]
The clock function calculates the current date and time from
the system time.
[c tf] = clock returns a second output argument that is
1 (true) if the current date and time
occur during Daylight Saving Time (DST) in your system's time zone, and
0 (false) otherwise.
MATLAB® Online™ returns current Coordinated Universal Time (UTC) rather than local time.
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.
To return a datetime scalar representing the current date and time, type:
t = datetime('now')