timeofday
Time elapsed since midnight for each datetime.
Category: Language Fundamentals > Data Types
Syntax
t = timeofday(d)
Returns, as a duration, the time of day of each datetime in d.
Description
The date part is discarded and only the clock time remains, which makes it simple to compare times across different days. Convert the result to numbers with hours, minutes or seconds: hours(timeofday(d)) is the time of day in decimal hours.
For a datetime with a time zone, the local clock time in that zone is used.
Input arguments
d- datetime array.
Output arguments
t- Duration array of the same size, from
00:00:00up to just under 24 hours.
Example
Clock time and decimal hours
d = datetime(2024,3,5,14,30,15);
timeofday(d)
hours(timeofday(d))
Output
ans = duration
14:30:15
ans = 14.5042