How to convert python datetime to date?

Mahabubur Rahman
0

How to convert python datetime to date?

---------------------------------------

Solustion:

  • Import datetime
  • get current datetime
  • convert the datetime to date using python date() function

Step 1: Import datetime
>>> import datetime

 Step 2:  See the current date-time 

>>> datetime.datetime.now()
datetime.datetime(2021, 6, 10, 1, 5, 41, 386435)

Step 3:  Now convert it to date using date() function as bellow -

>>> datetime.datetime.now().date()
datetime.date(2021, 6, 10)

 

Post a Comment

0Comments
Post a Comment (0)