Convert timestamp to local datetime
import datetimetimestamp = 1563163320 # in seconds, not milisecondsd = datetime.datetime.fromtimestamp(timestamp) # to local timeprint(d.strftime('%Y-%m-%d %H:%M:%S')) # '2019-07-15 12:02:00'
Convert timestamp to UTC datetime
d = datetime.datetime.utcfromtimestamp(timestamp)
Get current timestamp
import timetimestamp_seconds = int(time.time())timestamp_miliseconds = int(time.time()*1000)
Convert DateTime to Timestamp
d = datetime.datetime.now()timestamp = d.timestamp()
Convert DateTime to UTC Timestamp
utc_timestamp = d.replace(tzinfo=datetime.timezone.utc).timestamp()