scipp.datetime(value, *, unit=<automatically deduced unit>)#

Constructs a zero dimensional Variable with a dtype of datetime64.

  • value (str | int | datetime64) –

    • str: Interpret the string according to the ISO 8601 date time format.

    • int: Number of time units (see argument unit) since Scipp’s epoch (see scipp.epoch()).

    • np.datetime64: Construct equivalent datetime of Scipp.

  • unit (Unit of the resulting datetime.) – Can be deduced if value is a str or np.datetime64 but is required if it is an int.


Variable – A scalar variable containing a datetime.

See also

scipp.datetimes, scipp.epoch


‘Dates and Times’ section in Data Types


>>> sc.datetime('2021-01-10T14:16:15')
<scipp.Variable> ()  datetime64              [s]  2021-01-10T14:16:15
>>> sc.datetime('2021-01-10T14:16:15', unit='ns')
<scipp.Variable> ()  datetime64             [ns]  2021-01-10T14:16:15.000000000
>>> sc.datetime(1610288175, unit='s')
<scipp.Variable> ()  datetime64              [s]  2021-01-10T14:16:15

Get the current time:

>>> now = sc.datetime('now', unit='s')