Skip to main content
`Ctrl`+`K`

# pandas.Timestamp.fromtimestamp

classmethod Timestamp.fromtimestamp(ts, tz=None)

  Create a Timestamp object from a POSIX timestamp.

  This method converts a POSIX timestamp (the number of seconds since January 1, 1970, 00:00:00 UTC) into a Timestamp object. The resulting Timestamp can be localized to a specific time zone if provided.

  Parameters:
    ts float

      The POSIX timestamp to convert, representing seconds since the epoch (1970-01-01 00:00:00 UTC).

    tz str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile, optional

      Time zone for the Timestamp. If not provided, the Timestamp will be timezone-naive (i.e., without time zone information).

  Returns:
    Timestamp

      A Timestamp object representing the given POSIX timestamp.

  See also

  `Timestamp`

    Represents a single timestamp, similar to datetime.

  `to_datetime`

    Converts various types of data to datetime.

  `datetime.datetime.fromtimestamp`

    Returns a datetime from a POSIX timestamp.

  Examples

  Convert a POSIX timestamp to a Timestamp:

      >>> pd.Timestamp.fromtimestamp(1584199972)
      Timestamp('2020-03-14 15:32:52')

  Note that the output may change depending on your local time and time zone:

      >>> pd.Timestamp.fromtimestamp(1584199972, tz='UTC')
      Timestamp('2020-03-14 15:32:52+0000', tz='UTC')