Python Programming - Console Input/Output - Discussion

Discussion Forum : Console Input/Output - General Questions (Q.No. 32)
32.
How can you print the current date and time in a specific format?
print(datetime.now())
print(now.strftime("%Y-%m-%d %H:%M:%S"))
print("Current date and time:", datetime.now())
print(f"Current date and time: {now}")
Answer: Option
Explanation:
To print the current date and time in a specific format, use strftime("%Y-%m-%d %H:%M:%S") with the datetime object.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.