Python 3 Datetime Library Script to Get the Current Date Time in Days,Months,Years,Hours,Minutes and Seconds Full Project For Beginners

Python 3 Datetime Library Script to Get the Current Date Time in Days,Months,Years,Hours,Minutes and Seconds Full Project For Beginners

 

Welcome folks today in this blog post we will be getting current date time in python using the datetime library. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to install the following library by typing the below command as shown below

 

pip install datetime

 

After installing this library you need to make an app.py file and copy paste the following code

 

app.py

 

import datetime
date_time = datetime.datetime.now()

date = date_time.date()  # Gives the date
time = date_time.time()  # Gives the time

print(date.year)
print(date.month)
print(date.day)
print(time.hour)
print(time.minute)
print(time.second)
print(time.microsecond)

 

See also  Python 3 Reportlab Invoice Billing or Receipt PDF Document Generator Using pyinvoice Library Full Project For Beginners

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

 

Leave a Reply