gfw.common.datetime.datetime_from_timestamp#

datetime_from_timestamp(ts, tz=datetime.timezone.utc)[source]#

Converts a Unix timestamp to a timezone-aware datetime.

By default, the timestamp is converted to UTC. If you need a different timezone, specify it using the tz argument.

Parameters:
  • ts (int | float) – The Unix timestamp to convert.

  • tz (tzinfo) – The timezone to apply. Defaults to UTC.

Returns:

A timezone-aware datetime

object corresponding to the given timestamp.

Return type:

datetime