I've got this date time string:
post["date"] = "2007-07-18 10:03:19"
I'd like to extract just "2007-07-18" as a date. I've seen some reference to strptime
but I'm not sure how to use it. How can I extract the date from this string?
datetimepython
I've got this date time string:
post["date"] = "2007-07-18 10:03:19"
I'd like to extract just "2007-07-18" as a date. I've seen some reference to strptime
but I'm not sure how to use it. How can I extract the date from this string?
Best Solution
The other two answers are fine, but if you actually want the date for something else, you can use the
datetime
module:It might be overkill for now, but it'll come in useful. You can see all of the format specifiers here.