datetime

Methods

Method Reference: datetime.posixtime

datetime: P = posixtime (T)

Convert datetime array to POSIX time.

P = posixtime (T) returns the number of seconds elapsed since the epoch 1970-01-01 00:00:00 UTC for each element of the input datetime array T. The output P is a double array of the same size as T and includes any fractional seconds. Datetime arrays without a time zone are treated as UTC. Not-A-Time (NaT) values are returned as NaN.

POSIX time has no stamp of its own for an inserted leap second, so for a 'UTCLeapSeconds' array the 60th second of a minute shares the stamp of the second that follows it: posixtime of 2016-12-31T23:59:60Z and of 2017-01-01T00:00:00Z are both 1483228800. Every other conversion folds the other way (see convertTo).

Source Code: datetime

posixtime returns seconds since the Unix epoch (1970-01-01 UTC). A datetime without a time zone is treated as UTC.

 t = datetime (2024, 3, 9, 6, 0, 0)
t =
  datetime

   09-Mar-2024 06:00:00
 posixtime (t)
ans = 1.7100e+09