now
Current date and time as serial date number
Syntax
Description
Note
The now
function returns a serial date number that represents
the current time. However, it is recommended that you use datetime
values to represent points in time. To return the current time as
a datetime
value, use the datetime('now')
syntax.
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
datetime
value, 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('now'))
string(datetime('now'))
datetime('now')
Current date and time as a
datetime
valuedatetime(now,'ConvertFrom','datenum')