29 lines
950 B
Python
29 lines
950 B
Python
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
d = datetime(year=2020, month=11, day=4, hour=14, minute=53, second=0)
|
||
|
|
|
||
|
|
# Direttive usate con strftime:
|
||
|
|
# %Y anno con 4 cifre -> 2020
|
||
|
|
# %y anno con 2 cifre -> 20
|
||
|
|
# %m mese numerico -> 11
|
||
|
|
# %B nome mese completo -> November
|
||
|
|
# %b nome mese abbreviato -> Nov
|
||
|
|
# %d giorno del mese -> 04
|
||
|
|
# %H ora formato 24h -> 14
|
||
|
|
# %M minuti -> 53
|
||
|
|
# %S secondi -> 00
|
||
|
|
# %p AM/PM -> PM
|
||
|
|
# %a giorno abbreviato -> Wed
|
||
|
|
# %A giorno completo -> Wednesday
|
||
|
|
# %w giorno settimana -> 3
|
||
|
|
# %j giorno dell'anno -> 309
|
||
|
|
# %W numero settimana -> 44
|
||
|
|
|
||
|
|
print(d.strftime("%Y/%m/%d %H:%M:%S"))
|
||
|
|
print(d.strftime("%y/%B/%d %H:%M:%S %p"))
|
||
|
|
print(d.strftime("%a, %Y %b %d"))
|
||
|
|
print(d.strftime("%A, %Y %B %d"))
|
||
|
|
print(d.strftime("Weekday: %w"))
|
||
|
|
print(d.strftime("Day of the year: %j"))
|
||
|
|
print(d.strftime("Week number of the year: %W"))
|