Navigation

Operators and Keywords

Function List:

C++ API

: v = datevec (date)
: v = datevec (date, f)
: v = datevec (date, p)
: v = datevec (date, f, p)
: [y, m, d, h, mi, s] = datevec (…)

Convert a serial date number (see datenum) or date string (see datestr) into a date vector.

A date vector is a row vector with six members, representing the year, month, day, hour, minute, and seconds respectively.

f is the format string used to interpret date strings (see datestr). If date is a string, but no format is specified, then a relatively slow search is performed through various formats. It is always preferable to specify the format string f if it is known. Formats which do not specify a particular time component will have the value set to zero. Formats which do not specify a date will default to January 1st of the current year.

p is the year at the start of the century to which two-digit years will be referenced. If not specified, it defaults to the current year minus 50.

See also: datenum, datestr, clock, now, date.

Demonstration 1

The following code

 ## Current date and time
 datevec (now ())

Produces the following output

ans =

   2017.0000      1.0000      2.0000     11.0000     55.0000     23.1812

Package: octave