Documentation

hour

Hour number

Syntax

Description

example

h = hour(t)returns the hour numbers of the datetime values int. Thehoutput is adoublearray the same size astand contains integer values from 0 to 23.

Thehourfunction returns the hour numbers of datetime values. To assign hour values to a datetime array,t, uset.Hourand modify theHourproperty.

Examples

collapse all

t = datetime('today'):hours(8):datetime('tomorrow'); t.Format ='MMM dd, HH:mm'
t =1x4 datetime arrayFeb 01, 00:00 Feb 01, 08:00 Feb 01, 16:00 Feb 02, 00:00
h = hour(t)
h =1×40 8 16 0

Input Arguments

collapse all

Input date and time, specified as adatetimearray.

Extended Capabilities

Introduced in R2014b