8.Write a Python program to perform table pivoting and Data/time functionality


from datetime import date
 
# date object of today's date
today = date.today()
 
print("Current year:", today.year)
print("Current month:", today.month)
print("Current day:", today.day)

from datetime import date
 
# calling the today
# function of date class
today = date.today()
 
print("Today's date is", today)

from datetime import time
 
Time = time(11, 34, 56)
 
print("hour =", Time.hour)
print("minute =", Time.minute)
print("second =", Time.second)
print("microsecond =", Time.microsecond)

from datetime import datetime
 
# Initializing constructor
a = datetime(1999, 12, 12)
print(a)
 
# Initializing constructor
# with time parameters as well
a = datetime(1999, 12, 12, 12, 12, 12, 342380)
print(a)

from datetime import datetime
 
# Calling now() function
today = datetime.now()
print("Current date and time is", today) 


Post a Comment

0 Comments