Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

hms

Hour, minute, and second numbers of duration

Syntax

[h,m,s] = hms(t)

Description

example

[h,m,s] = hms(t) returns the hour, minute, and second values of the datetime values in t as separate numeric arrays. The h and m outputs contain integer values, and the s output can contain a fractional part. h, m, and s are the same size as t.

Calling hms is equivalent to calling the hour, minute, and second functions.

Examples

collapse all

t1 = datetime('now','Format','HH:mm:ss.SSS');
t = t1 + minutes(0:45:135)
t = 1x4 datetime array
   18:13:17.497   18:58:17.497   19:43:17.497   20:28:17.497

[h,m,s] = hms(t)
h = 

    18    18    19    20

m = 

    13    58    43    28

s = 

   17.4979   17.4979   17.4979   17.4979

hms returns the hour, minute, and second numbers in separate arrays.

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Output Arguments

collapse all

Hour numbers, returned as a numeric array of integer values from 0 to 23. The h output is of type double and is the same size as t.

Minute numbers, returned as a numeric array of integer values from 0 to 59. The m output is of type double and is the same size as t.

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 is UTCLeapSeconds, the s output can contain a value between 60 and 61 for times that fall during a leap second occurrence. The s output is of type double and is the same size as t.

Extended Capabilities

See Also

| | |

Introduced in R2014b

Was this topic helpful?