Hi, how would I be able to convert the timestamp g...
# ask-community
n
Hi, how would I be able to convert the timestamp given in the asset materialization event to datetime format? For example, the given timestamp is 1687446078.4361758, which corresponds to Jun 22, 11:01 AM.
dagster bot responded by community 1
a
Hi - This is a Unix Timestamp. Here's an example of how to use Python's datetime and tzlocal libraries to convert it to a human readable string:
Copy code
from datetime import datetime, timezone
import tzlocal

def human_readable_date_with_tz(posix: float, tz: timezone = tzlocal.get_localzone()) -> str:
    converted_unix = datetime.fromtimestamp(posix, tz)
    return datetime.strftime(converted_unix, "%Y-%m-%dT%H:%M:%S %z")