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
DTis adatetimearray with no time zone, then the outputTis also equal toE = hours(DT.Hour) + minutes(DT.Minute) + seconds(DT.Second)
If
DThas itsTimeZoneproperty set to a time zone that does not observe DST, thenTis equal toE.If
DThas itsTimeZoneproperty set to a time zone that observes DST, thentimeofdayaccounts for the DST shift on days when the shift occurs. On those days, for times after the DST shift occurs,Tdiffers fromEby the amount of the shift.
Extended Capabilities
Version History
Introduced in R2014b