datetime Flashcards
import datetime
a = datetime.date(2018,11,28)
print(a.day)
28
import datetime
a = datetime.date(2018,11,28)
print(a.month)
11
import datetime
a = datetime.date(2018,11,28)
print(a.year)
2018
from datetime import time
print(time(11,34,56))
11:34:56
from datetime import time
a = time(11,34,56)
print(a.hour)
11
from datetime import time
a = time(11,34,56)
print(a.minute)
34
from datetime import time
a = time(11,34,56)
print(a.second)
56
import datetime
x = datetime.datetime(2018, 6, 1)
print(x.strftime(“%A”))
#Day of the week Friday
import datetime
x = datetime.datetime(2018, 6, 1)
print(x.strftime(“%Y”))
2018
import datetime
x = datetime.datetime(2018, 6, 1)
print(x.strftime(“%j”))
#The number of the year 152
import datetime
x = datetime.datetime(2018, 6, 1)
print(x.strftime(“%W”))
#Week of the year 22