This commit is contained in:
hugogogo
2025-10-25 17:48:22 +02:00
parent bad537a0c3
commit e9b31175f6

View File

@@ -0,0 +1,16 @@
import datetime as dt
# https://docs.python.org/3.10/library/datetime.html?highlight=time#datetime.datetime
now = dt.datetime.now()
epoch = dt.datetime(1970, 1, 1)
# https://docs.python.org/3.10/library/datetime.html?highlight=time#strftime-and-strptime-behavior
formatDate = now.strftime("%b %d %Y")
delta = now - epoch
deltaInSeconds = delta.total_seconds()
deltaInSecondsStr = "{:,.3f}".format(float(deltaInSeconds))
deltaInScientificStr = "{:.2e}".format(float(deltaInSeconds))
print("Seconds since January 1, 1970: " + deltaInSecondsStr + " or " + deltaInScientificStr + " in scientific notation\n" + formatDate)