

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert a Python date string to a date object?
You can convert a string to date object using the strptime function. Provide the date string and the format in which the date is specified.
example
import datetime date_str = '29122017' # The date - 29 Dec 2017 format_str = '%d%m%Y' # The format datetime_obj = datetime.datetime.strptime(date_str, format_str) print(datetime_obj.date())
Output
This will give the output −
2017-12-29
- Related Questions & Answers
- How to convert a JS Date to a Python date object?
- How to convert a JavaScript date object to a string?
- How to convert a string in to date object in JavaScript?
- How to convert a String into a Date object using JDBC API?
- How to convert a Date object to LocalDate object in java?
- How to convert an integer into a date object in Python?
- How to convert a MySQL date to JavaScript date?
- How to convert a date object to string with format hh:mm:ss in JavaScript?
- How to convert a string to date in MySQL?
- How to create JavaScript Date object from date string?
- Java Program to convert a String to Date
- Convert date string to timestamp in Python
- How to convert a Date value to string in JDBC?
- How to correctly convert a date format into a MySQL date?
- How to convert ISO 8601 string to Date/time object in Android?
Advertisements