RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • calendarDuration
    • dateshift
    • datetime
    • day
    • duration
    • hour
    • minute
    • month
    • second
    • year

datetime — Create host datetime arrays from date vectors, text, calendar components, or explicit serial-date conversions.

datetime constructs host-side datetime objects from m-by-3 or m-by-6 date vectors, text, and the documented 3-, 6-, or 7-component forms. All eight integer classes are read from authoritative storage before RunMat crosses into its current floating serial-date representation. ConvertFrom='datenum' is implemented; other documented conversion epochs, time zones, locale and pivot-year options, and general nanosecond fidelity remain explicit gaps.

Syntax

t = datetime()
t = datetime(textOrArray)
t = datetime(dateVectors)
t = datetime(year, month, day)
t = datetime(year, month, day, hour, minute, second)
t = datetime(year, month, day, hour, minute, second, millisecond)
All supported datetime forms
t = datetime()
t = datetime(textOrArray)
t = datetime(dateVectors)
t = datetime(year, month, day)
t = datetime(year, month, day, hour, minute, second)
t = datetime(year, month, day, hour, minute, second, millisecond)
t = datetime(serialDateNumbers, "ConvertFrom", "datenum")
t = datetime(___, "Format", format)
t = datetime(textOrArray, "InputFormat", inputFormat)
t = datetime(___, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
textOrArrayAnyYes—String/char/date text input.
dateVectorsNumericArrayYes—An m-by-3 or m-by-6 numeric date-vector matrix.
yearNumericArrayYes—Year component.
monthNumericArrayYes—Month component.
dayNumericArrayYes—Day component.
hourNumericArrayYes—Hour component.
minuteNumericArrayYes—Minute component.
secondNumericArrayYes—Second component.
argsAnyVariadic—Datetime constructor arguments.
argsAnyVariadic—Numeric serial input with ConvertFrom option.

Returns

NameTypeDescription
tAnyDatetime object result.

Errors

IdentifierWhenMessage
RunMat:datetime:InvalidArgumentArguments or option grammar do not match supported datetime forms.datetime: invalid argument
RunMat:datetime:InvalidInputInput values cannot be parsed/converted/broadcast to a valid datetime result.datetime: invalid input
RunMat:datetime:InternalInternal datetime state or indexing/evaluation failed unexpectedly.datetime: internal operation failed

How datetime works

  • datetime() with no arguments returns the current local date and time.
  • datetime(dateVectors) accepts m-by-3 and m-by-6 numeric matrices. datetime(Y, M, D), datetime(Y, M, D, H, MN, S), and datetime(Y, M, D, H, MN, S, MS) accept single, double, and all eight integer classes; scalar inputs expand to matching non-scalar component arrays.
  • Calendar components normalize by carrying into adjacent units. NaN components produce NaT and infinite components retain the corresponding infinite serial marker within the current host representation.
  • datetime(text) accepts string scalars, string arrays, and character vectors. Supported text includes common ISO-like forms, dd-MMM-yyyy, now, today, tomorrow, and yesterday.
  • datetime(serials, 'ConvertFrom', 'datenum') interprets numeric values as MATLAB serial date numbers.
  • A one-argument numeric value that is not an m-by-3 or m-by-6 date-vector matrix is interpreted as a raw serial date only when RunMat compatibility extensions are enabled. MATLAB-compatible mode requires the explicit ConvertFrom form.
  • Four- and five-component forms, logical numeric inputs, and gathering resident numeric arrays are compatibility-gated RunMat extensions. The resident gate is checked before provider access and the result is always a host datetime object.
  • Only Format, InputFormat, and ConvertFrom='datenum' are currently implemented. Other documented ConvertFrom values and the Locale, PivotYear, TimeZone, Epoch, and TicksPerSecond options report unsupported-input errors rather than silently approximating semantics.
  • The Format property controls text rendering. Assigning t.Format = 'yyyy-MM-dd HH:mm:ss' updates how the object displays without changing the stored point in time.
  • Linear indexing t(k) is supported and returns datetime values.
  • Comparison operators and plus/minus day arithmetic are supported. Subtracting two datetime values returns numeric day deltas.
  • now, today, and clock expose current local time in MATLAB-compatible serial, datetime, and date-vector forms.
  • datenum, datevec, datestr, weekday, eomday, etime, and isbetween cover common legacy serial-date conversion, formatting, query, and interval operations.
  • datetime + calendarDuration and datetime - calendarDuration apply month-aware calendar arithmetic with end-of-month clamping.
  • isbusday, holidays, busdays, days252bus, daysdif, fbusdate, and lbusdate provide weekday plus market-holiday business-calendar compatibility for standard scripts. Custom weekend definitions and all Financial Toolbox option forms are not yet implemented.

Does RunMat run datetime on the GPU?

datetime does not allocate GPU objects or invoke provider kernels. MATLAB-compatible mode rejects resident inputs before lookup; RunMat extension mode gathers before building the host object.

GPU memory and residency

No. RunMat represents datetime values as host-side objects with an internal serial-date tensor and a Format property. Resident numeric constructor input is compatibility-gated before provider access, and an enabled extension gathers to a CPU result.

Examples

Constructing a scalar datetime from numeric components

t = datetime(2024, 4, 9, 13, 30, 0)

Expected output:

t =
  09-Apr-2024 13:30:00

Parsing text into datetimes

t = datetime(["2024-04-09 13:30:00"; "2024-04-10 08:15:00"])

Expected output:

t =
09-Apr-2024 13:30:00
10-Apr-2024 08:15:00

Creating datetimes from serial date numbers

d = datetime([739351; 739352], 'ConvertFrom', 'datenum')

Expected output:

d =
09-Apr-2024 00:00:00
10-Apr-2024 00:00:00

Changing display format without changing the stored value

t = datetime(2024, 4, 9, 13, 30, 0);
t.Format = 'yyyy-MM-dd HH:mm:ss';
disp(t)

Expected output:

2024-04-09 13:30:00

Extracting calendar and clock components

t = datetime(2024, 4, 9, 13, 30, 5);
y = year(t)
m = month(t)
d = day(t)
h = hour(t)

Expected output:

y = 2024
m = 4
d = 9
h = 13

Adding days and subtracting datetimes

t0 = datetime(2024, 4, 9);
t1 = t0 + 7;
delta = t1 - t0

Expected output:

delta = 7

Using serial-date conversion helpers

n = datenum(2024, 4, 9);
v = datevec(n);
s = datestr(n, 'yyyy-MM-dd')

Expected output:

s =
  2024-04-09

Adding a calendar month clamps at month end

t = datetime(2024, 1, 31, 'Format', 'yyyy-MM-dd');
t + calmonths(1)

Expected output:

ans =
  2024-02-29

Using datetime with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how datetime changes the result.

Run a small datetime example, explain the result, then change one input and compare the output.

FAQ

What does the Format property change?⌄

Only the textual representation. The stored serial date number is unchanged, so comparisons and arithmetic still refer to the same instant.

How is subtraction interpreted?⌄

Subtracting one datetime from another returns a numeric delta measured in days. Subtracting a numeric value from a datetime shifts it backward by that many days.

Can I index datetime arrays?⌄

Yes. Linear () indexing is supported and preserves the datetime type.

Does datetime run on the GPU?⌄

No public resident datetime type is implemented. MATLAB-compatible mode rejects resident numeric constructor inputs before provider access; RunMat extension mode may gather them and still returns a host-side datetime object.

Related Datetime functions

calendarDuration · dateshift · day · duration · hour · minute · month · second · year

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how datetime is executed, line by line, in Rust.

  • View the source for datetime in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How datetime works
  • Does RunMat run datetime on the GPU?
  • GPU memory and residency
  • Examples
  • Constructing a scalar datetime from numeric components
  • Parsing text into datetimes
  • Creating datetimes from serial date numbers
  • Changing display format without changing the stored value
  • Extracting calendar and clock components
  • Adding days and subtracting datetimes
  • Using serial-date conversion helpers
  • Adding a calendar month clamps at month end
  • Using datetime with coding agents
  • FAQ
  • Related Datetime functions
  • Open-source implementation
  • About RunMat