Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

hour

Syntax

h = hour(t)

Description

example

h = hour(t) returns the hour numbers of the datetime values in t. The h output is a double array the same size as t and contains integer values from 0 to 23.

The hour function returns the hour numbers of datetime values. To assign hour values to a datetime array, t, use t.Hour and modify the Hour property.

Examples

collapse all

t = datetime('today'):hours(8):datetime('tomorrow');
t.Format = 'MMM dd, HH:mm'
t = 1x4 datetime array
   Mar 16, 00:00   Mar 16, 08:00   Mar 16, 16:00   Mar 17, 00:00

h = hour(t)
h = 1×4

     0     8    16     0

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Extended Capabilities

See Also

| | |

Introduced in R2014b

Was this topic helpful?