Create a Pandas program to create
• Datetime object for Jan 15 2012.
• Specific date and time of 9:20 pm.
• Local date and time.
• A date without time.
• Current date.
• Time from a datetime.
• Current local time.
import datetime
from datetime import datetime
print("Datetime object for Jan 11 2012:", datetime(2012, 1, 11))
print("\nSpecific date and time of 9:20 pm", datetime(2011, 1, 11, 21, 20))
print("\nLocal date and time:", datetime.now())
print("\nA date without time: ", datetime.date(datetime(2012, 5, 18)))
print("\nCurrent date:", datetime.now().date())
print("\nTime from a datetime:", datetime.time(datetime(2012, 12, 15, 18, 12)))
print("\nCurrent local time:", datetime.now().time())
Comments
Leave a comment