4

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?

1
  • 1
    print date.date()? Commented Aug 16, 2014 at 20:13

1 Answer 1

9

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.