Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert string to date without time in python

Tags:

python

django

I am converting a string to date like this:

date=request.GET.get('date','')
    if date:
        date = datetime.strptime(date, "%m/%d/%Y")
        print date

This prints:

2014-08-08 00:00:00

How can I get the date without the 00:00:00 time?

like image 444
Atma Avatar asked Sep 15 '25 08:09

Atma


1 Answers

You have a "datetime" object, hence the time part.

As @jonrsharpe mentioned in his comment, it's

print date.date() (output in ISO format)

or print date.strftime('%d/%m/%Y')

in your given input format.

like image 185
ngulam Avatar answered Sep 17 '25 23:09

ngulam