Hier ein paar Beispiele
import time
x = time.time()
print("Timestamp:", x)
import datetime
now = datetime.datetime.now()
print(now) # Ausgabe 'YYYY-MM-DD HH:MM:SS.ssssss'
# "from datetime import datetime as .." to get timestamp from datetime
from datetime import datetime as dt
curr_dt = dt.now()
timestamp = int(round(curr_dt.timestamp()))
print("Integer timestamp of current datetime: ", timestamp)
fmt_d = now.strftime("%d.%m.%Y")
fmt_t = now.strftime("%H:%M:%S")
print("Formatiertes Datum:", fmt_d)
print("Formatierte Zeit:", fmt_t)
datum_und_zeit_str = "06-02-1960 14:30:00"
datum_und_zeit = datetime.datetime.strptime(datum_und_zeit_str, "%d-%m-%Y %H:%M:%S")
print("Als Zeichenkette:", datum_und_zeit)