42. Strftime Function in Python with Code || Date Time Module-II Programming Tutorial

Veröffentlicht am: 11 August 2022
auf dem Kanal: Bhavatavi
48
0

The strftime() function is used to convert date and time objects to their string representation. It takes one or more input of formatted code and returns the string representation.

Code:
from datetime import datetime
now=datetime.now()
print(now)

year=now.strftime("%Y")
print("Year:",year)

month=now.strftime("%m")
print("Month:",month)
day=now.strftime("%d")
print("Day:",day)

time=now.strftime("%H:%M:%S")
print("Time:",time)

date_time1=now.strftime("%d%m%Y, %H:%M:%S")
print("date and time:",date_time1)

timestamp=1668797322
date_time=datetime.fromtimestamp(timestamp)

print("Date time object",date_time)

d=date_time.strftime("%m%d%Y, %H:%M:%S")
print("Output 2:",d)

d=date_time.strftime("%d %B,%Y")
print("Output 3:",d)

d=date_time.strftime("%I%p")
print("Output 4",d)


Auf dieser Seite können Sie das Online-Video 42. Strftime Function in Python with Code || Date Time Module-II Programming Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Bhavatavi 11 August 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 48 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!