datetime

Methods

Method Reference: datetime.hms

datetime: [h, m, s] = hms (T)

Hour, Minute, and Second components of a datetime array.

[h, m, s] = hms (T) returns the hour, minute, and second components of the corresponding datetime values in T as separate numeric arrays. h and m contain integer values and s may also contain a fractional part. All outputs have the same size as T. Not-A-Time (NaT) values in T are returned as NaN in the output arrays.

Source Code: datetime

hms splits each datetime into its hour, minute and second components.

 t = datetime (2024, 3, 9, 14, 30, 45)
t =
  datetime

   09-Mar-2024 14:30:45
 [h, m, s] = hms (t);
 [h, m, s]
ans =

   14   30   45