Current date as character vector
date function returns text that represents the current
date. However, it is recommended that you use
datetime values to represent points in time. To return the current date as
datetime value, use the
syntax. Then convert the
datetime value to text by using the
c = date returns the current date as a character vector in the
This format represents the day of the month (
dd) as a number, the
month name (
MMM) as its three-letter abbreviation, and the year
yyyy) as a number.
Return Current Date
To return the current date as a character vector, use the
c = date
c = '26-Feb-2022'
datealways returns the English abbreviation for the month name. The function does not take your system locale into account when determining the month name.
MATLAB® Online™ determines the current date from Coordinated Universal Time (UTC) rather than from local time.
As an alternative, use the
datetimefunction to represent the current date.
d = datetime('today')
datetimefunction takes your locale into account. Also, you can specify the format that a
datetimearray uses to represent its values.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.