Skip to content

datevec

time · scripts/time/datevec.m

: dv = datevec (d)
: dv = datevec (str)
: dv = datevec (str, fmt)
: dv = datevec (str, fmt, pivot)
: [y, m, d, h, mi, s] = datevec (…)

Split serial date numbers or date strings into year, month, day, hour, minute and second.

Numeric input is taken as serial dates; the time of day is rounded to the nearest millisecond. Strings are matched against fmt (made of the datestr tokens, or a predefined format number 0 to 31); without a format a list of common layouts is tried. Two-digit years are mapped to the 100-year window that starts at pivot (default: current year minus 50).