Main Content


(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.



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


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


collapse all

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

Date = today
Date = 739294

Use the optional argument outputType to return a datetime array.

Date = today("datetime")
Date = datetime

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

R2022a: Not recommended

There are no plans to remove today. However, the datetime function is recommended instead because it returns a datetime value. The datetime data type provides flexible date and time formats, storage out to nanosecond precision, and properties to account for time zones and daylight saving time.

To return the current date, call datetime with "today" as the input argument.

currentDate = datetime("today")

To convert currentDate to a string, use the string function.

currentDateString = string(currentDate)

To convert currentDate to a serial date number, use the convertTo function.

currentDateNum = convertTo(currentDate,"datenum")