today

Current date as a serial date number (no time of day).

Category: Language Fundamentals > Data Types

Syntax

d = today

Returns the current local date as a double.

Description

today returns a serial date number and is mostly kept for compatibility with datenum-style code. New code should use datetime('today'), which gives a datetime that displays as a date, and datestr or datetime formats to print it.

Because the result depends on the day it runs, avoid comparing it with fixed numbers in tests; check its class or an inequality with an older date.

Output arguments

d
Whole number of days since the datenum origin (January 0, year 0), identical to floor(now).

Example

Class and sanity checks

d = today();
class(d)
d > 738000
d == floor(d)
Output
ans = 'double'
ans = logical
   1
ans = logical
   1

See also

now datetime datenum datestr clock