Exp No 4 Write a python script to print the current date in the following format “Sun May 29 02:26:23 IST 2017
from datetime import datetime
today =datetime.today()
dd/mm/YY
d1 =today.strftime("%d/%m/%Y")
print("d1 =", d1)
mm/dd/y
d2 =today.strftime("%m/%d/%y")
print("d2 =", d2)
Month abbreviation, day and year
d3 =today.strftime("%b-%d-%Y")
print("d3 =", d3)
Textual month, day and year
d4 =today.strftime("%B %d, %Y")
print("d4 =", d4)
Experiment format “Sun May 29 02:26:23 IST 2017
d5 =today.strftime("%a %b %d %H:%M:%S, IST %Y")
print("d5 =", d5)
INPUT AND OUTPUT:
d1 = 08/01/2024
d2 = 01/08/24
d3 = Jan-08-2024
d4 = January 08, 2024
d5 = Mon Jan 08 15:32:02, IST 2024
On this page of the site you can watch the video online PYTHON PROGRAMMING LAB Exp 4 with a duration of hours minute second in good quality, which was uploaded by the user DIWAKAR TIWARY 08 January 2024, share the link with friends and acquaintances, this video has already been watched 206 times on youtube and it was liked by 4 viewers. Enjoy your viewing!