now
(Not recommended; use datetime) Current date and time as serial
date number
now is not recommended. To return the current date and time as a
datetime value, use datetime instead. For more
information on updating your code, see Version History or Replace Discouraged Instances of Serial Date Numbers and Date Strings.
Syntax
Description
t = now returns the current date and time as a serial date number.
A serial date number represents the whole and fractional number of days starting from a
fixed, preset date (January 0,
0000).
Examples
Limitations
MATLAB® Online™ returns the current date and time in Coordinated Universal Time (UTC) rather than local time.
More About
Tips
To represent the current date and time as a serial date number, as text, or as a
datetimevalue, use the function calls shown in the table.Function Call
Output
floor(now)Current date as a serial date number
rem(now,1)Current time as a serial date number
datestr(now)Current date and time as text
char(datetime)string(datetime)datetimeCurrent date and time as a
datetimevaluedatetime(now,'ConvertFrom','datenum')