today - (Not recommended; use datetime("today")) Current
date - MATLAB ([original](https://in.mathworks.com/help/matlab/ref/today.html)) ([raw](?raw))
Main Content
(Not recommended; use datetime("today")
) Current date
Syntax
Description
[Date](#bu%5Fdvwg-1-Date) = today
returns the current date as a serial date number.
[Date](#bu%5Fdvwg-1-Date) = today([outputType](#bu%5Fdvwg-1-outputType))
returns the current date using an optional outputType
. The type of output is determined by an optional outputType
variable input.
Examples
Use today
to return the current date with the default serial date number.
Use the optional argument outputType
to return a datetime
array.
Date = datetime 01-Feb-2025
Input Arguments
Output data type, specified as "datenum"
or"datetime"
.
If outputType
is "datenum"
, thenDate
is a serial date number. IfoutputType
is "datetime"
, thenDate
is a datetime
value. By default, outputType
is "datenum"
.
Data Types: string
| char
Output Arguments
Current date, returned as a serial date number ordatetime
value, depending on the optional input argument outputType.
Version History
Introduced before R2006a
There are no plans to remove today
. However, the datetime function is recommended instead because it returns a datetime
value. Thedatetime
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 theconvertTo function.
currentDateNum = convertTo(currentDate,"datenum")
Previously, today
required Financial Toolbox™.