timeofday
Elapsed time since midnight for datetime
arrays
Description
returns the clock time for every day in the input T
= timeofday(DT
)datetime
array.
The function returns the clock times as a duration
array whose
values equal the elapsed time since midnight for each element in the
datetime
array.
For datetime
arrays without time zones, and in most other
cases, the elapsed time since midnight, E
, is equal
to
E = hours(DT.Hour) + minutes(DT.Minute) + seconds(DT.Second)
If DT
has its TimeZone
property set to a
time zone that respects Daylight Saving Time (DST), then
timeofday
takes DST into account. For more information, see
Algorithms.
The output argument T
is also equivalent to DT -
dateshift(DT,'start','day')
.
Examples
Input Arguments
Output Arguments
Algorithms
A datetime
array can have its TimeZone
property
set to a time zone that observes Daylight Saving Time (DST). The
timeofday
function takes DST into account.
If the input argument
DT
is adatetime
array with no time zone, then the outputT
is also equal toE = hours(DT.Hour) + minutes(DT.Minute) + seconds(DT.Second)
If
DT
has itsTimeZone
property set to a time zone that does not observe DST, thenT
is equal toE
.If
DT
has itsTimeZone
property set to a time zone that observes DST, thentimeofday
accounts for the DST shift on days when the shift occurs. On those days, for times after the DST shift occurs,T
differs fromE
by the amount of the shift.
Extended Capabilities
Version History
Introduced in R2014b