You need to make sure you provide input accordingly
datetime.strptime(date_string,date_string_format).strftime(convert_to_date_string_format)
To print the date in specified format you need to provide format as below.
import datetime d =datetime.datetime.strptime("01/27/2012","%m/%d/%Y").strftime('%m/%d/%Y') print d
Output:
01/27/2012
Related Posts:
- Getting today’s date in YYYY-MM-DD in Python?
- How to get the current time in Python
- Creating a range of dates in Python
- Converting string into datetime
- Converting string into datetime
- Difference between UTC and GMT
- Python datetime to string without microsecond component
- How do I get the current date and time in PHP?
- Convenient way to deal with ValueError: cannot reindex from a duplicate axis
- Converting string into datetime
- How to get current timestamp in string format in Java? “yyyy.MM.dd.HH.mm.ss”
- How to get the current date/time in Java [duplicate]
- What’s the difference between ISO 8601 and RFC 3339 Date Formats?
- How to get the current date/time in Java
- Can’t compare naive and aware datetime.now() <= challenge.datetime_end
- How to compare two dates?
- NOW() function in PHP
- Can only use .dt accessor with datetimelike values
- Converting between datetime and Pandas Timestamp objects
- How do I do a Date comparison in Javascript?
- How to convert string to datetime format in pandas python?
- Convert datetime to Unix timestamp and convert it back in python
- Convert date to datetime in Python
- Converting between java.time.LocalDateTime and java.util.Date
- How do I get the day of week given a date?
- Parse date string and change format
- Setting the Timezone for PHP in the php.ini file
- datetime to string with series in pandas
- Convert Pandas Column to DateTime
- Adding hours to JavaScript Date object?
- How do I find the time difference between two datetime objects in python?
- How do I calculate the date six months from the current date using the datetime Python module?
- Get current time in milliseconds in Python?
- How can I convert a datetime object to milliseconds since epoch (unix time) in Python?
- How to change the order of DataFrame columns?
- What does %s mean in a python format string?
- Invalid character in identifier
- Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?
- ‘str’ object does not support item assignment
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- Quicksort with Python
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- How to print an exception in Python?
- What are “named tuples” in Python?
- What do these operators mean (** , ^ , %, //)? [closed]
- Problem HTTP error 403 in Python 3 Web Scraping
- Python open() gives FileNotFoundError/IOError: Errno 2 No such file or directory
- Get the data received in a Flask request
- Python function execution
- Converting a String to DateTime
- Where do I find the bashrc file on Mac?
- ValueError: setting an array element with a sequence
- Why does num = 100?
- How do order of operations go on Python?
- Python group by
- What is the difference between pip and conda?
- How to clear variables in ipython?
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- Python – How to fix “ValueError: not enough values to unpack (expected 2, got 1)”
- Flask Template Not found
- Making a collatz program automate the boring stuff
- sprintf like functionality in Python
- Reverse / invert a dictionary mapping
- using pip3: module “importlib._bootstrap” has no attribute “SourceFileLoader”
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- What’s the difference between a Python module and a Python package?
- How can I truncate a datetime in SQL Server?
- SyntaxError invalid token
- TypeError: ‘type’ object is not iterable – Iterating over object instances
- Moment js date time comparison
- How to check the version of scipy
- How to check if type of a variable is string?
- Viewing all defined variables
- Does JavaScript support array/list comprehensions like Python?
- Difference between two dates in Python
- ImportError: No module named win32com.client
- Error message “Linter pylint is not installed”
- How to create a numpy array of all True or all False?
- What is the quickest way to HTTP GET in Python?
- Pandas index column title or name
- Removing nan values from an array
- Python – While-Loop until list is empty
- ImportError: No module named xgboost
- How to properly create a HeatMap with Bokeh
- How to detect key presses?
- How do I merge lists in python? [duplicate]
- Python: What OS am I running on?
- creating a reverse method for a python list from scratch
- What does on_delete do on Django models?
- Convert floats to ints in Pandas?
- Unable to import tweepy module
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- TypeError: got multiple values for argument
- How can I recover the return value of a function passed to multiprocessing.Process?
- Python Remove last char from string and return it
- NameError: name ‘reduce’ is not defined in Python
- numpy : calculate the derivative of the softmax function
- Difference between exit(0) and exit(1) in Python
- IOError: [Errno 32] Broken pipe when piping: `prog.py | othercmd`
- Convert UTC date time to local date time