Code 45: Python program to print the current Date and Time | Datetime Module | 365 Days of Code

Опубликовано: 14 Декабрь 2024
на канале: Code House
384
4

Here is the program to print the current Date and Time using Python.
Code -
import datetime
curr_dt = datetime.datetime.now()
print(curr_dt) # Complete Date and Time
print(curr_dt.day) # Only Date
print(curr_dt.month) # Only Month
print(curr_dt.year) # Only Year
print(curr_dt.hour) # Only Hour
print(curr_dt.minute) # Only Minutes
print(curr_dt.second) # Only Seconds

Thanks