ex01 ok
This commit is contained in:
16
d00/ex01/format_ft_time.py
Normal file
16
d00/ex01/format_ft_time.py
Normal 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)
|
||||||
Reference in New Issue
Block a user