This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

now

Current date and time as serial date number

Syntax

t = now

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 from a fixed, preset date (January 0, 0000).

Examples

t1 = now, t2 = rem(now,1)

t1 =

   7.2908e+05


t2 =

    0.4013

Limitations

  • MATLAB Online returns current Coordinated Universal Time (UTC) rather than local time.

Tips

  • To represent the current date and time as a date number, text, or 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

    datetime('now')

    Current date and time as a datetime value

    char(datetime('now')) or string(datetime('now'))

    Current date and time as text

Introduced before R2006a