How to convert google.protobuf.timestamp_pb2.Timestamp to datetime in Python

Assuming timestamp is your timestamp of type google.protobuf.timestamp_pb2.Timestamp, use this snippet to convert to datetime:

from datetime import datetime

timestamp_dt = datetime.fromtimestamp(timestamp.seconds + timestamp.nanos/1e9)