Hour, minute, and second numbers of datetime or duration
returns the hour, minute, and second values of the datetime or duration values in
t as separate numeric arrays. The
m outputs contain integer values, and the
s output can contain a fractional part.
s are the same size as
hms on a datetime array is equivalent to calling the
Find Hour, Minute, and Second Numbers of datetime Array
t1 = datetime('now','Format','HH:mm:ss.SSS'); t = t1 + minutes(0:45:135)
t = 1x4 datetime 03:38:43.474 04:23:43.474 05:08:43.474 05:53:43.474
[h,m,s] = hms(t)
h = 1×4 3 4 5 5
m = 1×4 38 23 8 53
s = 1×4 43.4746 43.4746 43.4746 43.4746
hms returns the hour, minute, and second numbers in separate arrays.
t — Input dates and times
datetime or duration array
Input dates and times, specified as a datetime or duration array.
h — Hour numbers
Hour numbers, returned as a numeric array of integer values from 0 to 23.
h output is of type
double and is
the same size as
m — Minute numbers
Minute numbers, returned as a numeric array of integer values from 0 to
m output is of type
is the same size as
s — Second numbers
Second numbers, returned as a numeric array of values from 0 to less than
60, and can include a fractional part. For datetime values whose time zone
s output can
contain a value between 60 and 61 for times that fall during a leap second
s output is of type
double and is the same size as
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced in R2014b