Main Content

today

(Not recommended; use datetime("today")) Current date

today is not recommended because it returns a serial date number. Instead, to return the current date as a datetime value, use the datetime function with "today" as the input argument. For more information on updating your code, see Version History or Replace Discouraged Instances of Serial Date Numbers and Date Strings.

Description

example

Date = today returns the current date as a serial date number.

example

Date = today(outputType) returns the current date using an optional outputType. The type of output is determined by an optional outputType variable input.

Examples

collapse all

Use today to return the current date with the default serial date number.

Date = today
Date = 738764

Use the optional argument outputType to return a datetime array.

Date = today("datetime")
Date = datetime
   31-Aug-2022

Input Arguments

collapse all

Output data type, specified as "datenum" or "datetime".

If outputType is "datenum", then Date is a serial date number. If outputType is "datetime", then Date is a datetime value. By default, outputType is "datenum".

Data Types: string | char

Output Arguments

collapse all

Current date, returned as a serial date number or datetime value, depending on the optional input argument outputType.

Version History

Introduced before R2006a

expand all