Skip to main content
Version: Python

to_np_datetime64

to_np_datetime64 converts a Java date-time to a numpy.datetime64.

danger

Avoid deephaven.time functions in query strings. Because deephaven.time provides functions that convert between Python and Java types, every call crosses the Python-Java boundary, which slows performance. For more information, see:

Syntax

to_np_datetime64(dt: Union[None, Instant, ZonedDateTime]) -> numpy.datetime64

Parameters

ParameterTypeDescription
dtUnion[None, Instant, ZonedDateTime]

A Java date-time to convert to a numpy.datetime64. If None is provided, None is returned.

Returns

Returns a numpy.datetime64.

Examples

from deephaven.time import dh_now, to_np_datetime64

np_now = to_np_datetime64(dh_now())

print(np_now, type(np_now))
from deephaven.time import dh_now, to_np_datetime64, to_j_zdt

zdt = to_j_zdt("2024-05-22 ET")

np_dt = to_np_datetime64(zdt)

print(np_dt)