-2

I am Trying to get the current date This is my code

import datetime

x = datetime.datetime.now()
print(x)

But I need Only Date not date and Time both

1 Answers1

-1
import datetime

x = datetime.datetime.now().strftime('%Y-%m-%d')
print(x)
EightShift
  • 71
  • 1
  • 5
  • Please don't post only code as an answer, but also provide an explanation of what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Yagiz Degirmenci Nov 10 '20 at 17:02