I assume I have import datetime before running each of the lines of code below

datetime.datetime.strptime("2013-1-25", '%Y-%m-%d').strftime('%m/%d/%y')

prints "01/25/13".

If you can't live with the leading zero, try this:

dt = datetime.datetime.strptime("2013-1-25", '%Y-%m-%d')
print '{0}/{1}/{2:02}'.format(dt.month, dt.day, dt.year % 100)

This prints "1/25/13".

EDIT: This may not work on every platform:

datetime.datetime.strptime("2013-1-25", '%Y-%m-%d').strftime('%m/%d/%y')
Answer from eumiro on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ formatting-dates-in-python
Formatting Dates in Python - GeeksforGeeks
July 12, 2025 - Conversion from string to date is many times needed while working with imported data sets from a CSV or when we take inputs from website forms. To do this, Python provides a method called strptime(). ... Date and time are different from strings ...
Discussions

What's a quick way to convert a date time stamp into RFC 822 format?
Use datetime.datetime.strptime to convert your string to a datetime object, then use the strftime method on that object to get the result you want. Check this handy site for the formatting strings: http://strftime.org/ More on reddit.com
๐ŸŒ r/Python
6
2
January 6, 2017
Trying to convert from 18-digit LDAP/FILETIME format to human readable
You can convert this to a UNIX timestamp with: offset=$((134774*24*60*60)) # number of days from Jan 1, 1601 to Jan 1, 1970, converted to seconds timestamp=131159832017796720 # you would read this from the file unixTimestamp=$((timestamp/10000000-offset)) # convert 100-nanosecond interval to second, adjust for offset date -d @$unixTimestamp # display that timestamp; specify a format with +%a%b%c or --rfc-2822 More on reddit.com
๐ŸŒ r/bash
9
2
September 30, 2016
Dates showing up as 5 digit numbers
the 5 digit number is the date value, (0 is 1/1/1900, and increases by 1 each day) you'll need to change the text format inside the formula, try this: =IF(A2=A1,C1&", "&TEXT(B2,"mm/dd/yyyy"), B2) or if c1 is the date, change the text function to be around C1 instead. You can also adjust the "mm/dd/yyyy" to be how you want the date formatted. More on reddit.com
๐ŸŒ r/excel
16
1
March 24, 2018
Unable to convert strings to datetime objects

I'll answer your question if you tell me which generator you used to come up with that user name.

More on reddit.com
๐ŸŒ r/bigquery
10
9
December 22, 2018
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ how-to-format-dates-in-python
How to Format Dates in Python
January 4, 2023 - You can now convert this date object to any other string format. Handling different separators is as easy as using them in the format string: from datetime import datetime str = '9-15-22' date_object = datetime.strptime(str, '%m-%d-%y') print(date_object) # 2022-09-15 00:00:00 ยท In this article, we studied how to format dates in Python.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-string-to-datetime-strptime
How To Convert a String to a datetime Object in Python | DigitalOcean
December 13, 2024 - 1. How to convert Python date string mm dd yyyy to datetime? To convert a date string in the mm dd yyyy format to a datetime object in Python, you can use the datetime.strptime method from the datetime module:
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ python datetime โ€บ python datetime format using strftime()
Python DateTime Format using Strftime() โ€“ PYnative
May 6, 2022 - Import datetime class using a from datetime import datetime statement. ... Use datetime.strftime(format) to convert a datetime object into a string as per the corresponding format.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ datetime โ€บ strftime
Python strftime() - datetime to string
Become a certified Python programmer. Try Programiz PRO! ... The strftime() method returns a string representing date and time using date, time or datetime object. The program below converts a datetime object containing current date and time to different string formats.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to convert between different date formats in python
How to Convert Between Different Date Formats in Python
August 13, 2024 - Date format conversion is the process ... tools for handling these conversions efficiently, primarily through the datetime module and the third-party dateutil library....
Find elsewhere
๐ŸŒ
Adverity
docs.adverity.com โ€บ reference โ€บ 2-enrich โ€บ python-expressions-for-managing-dates โ€บ converting-dates-from-one-format-in-to-another.html
Converting dates from one format to another โ€” Adverity Documentation documentation
Enter the date format to convert using date placeholders. For example, the date 01-03-2022 (1 March 2022) is in the date format %d-%m-%Y. format_to_use - This is the new format for the dates. Enter the new date format using date placeholders. See the examples section below for a worked example.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_datetime.asp
Python Datetime
The method is called strftime(), and takes one parameter, format, to specify the format of the returned string: ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ datetime.html
datetime โ€” Basic date and time types
The following example illustrates how any arguments besides days, seconds and microseconds are โ€œmergedโ€ and normalized into those three resulting attributes: >>> import datetime as dt >>> delta = dt.timedelta( ...
๐ŸŒ
Medium
medium.com โ€บ @generativeai.saif โ€บ how-to-convert-a-string-to-a-date-in-python-complete-guide-for-2025-bd5ece07c57c
How to Convert a String to a Date in Python: Complete Guide for 2025 | by Saif Ali | Medium
April 6, 2025 - Notice how the space between the date and time must be included in the format string. Every character in the input string needs a corresponding element in the format pattern. After converting a string to a datetime object, you might need just the date or time component. Python makes this easy with the .date() and .time() methods:
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ datetime
Python datetime Module: Working with Dates, Times, and Formatting
In this example, the string 2024-09-19 15:45:30 is converted into a datetime object using the format "%Y-%m-%d %H:%M:%S".
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ converting-strings-datetime-objects
Convert String to DateTime in Python: Complete Guide with Examples | DataCamp
June 8, 2018 - In Python, we can use the datetime.strptime() method to convert a string to a datetime object. The strptime() method takes two arguments: the string to be converted and a format string specifying the input string's format.
๐ŸŒ
Progress
blog.ipswitch.com โ€บ date-formatting-in-python
Date Formatting using Python Datetime and Strptime
November 13, 2024 - The strptime() method allows you to pass in a simple string like 2/4/18 and a simple formatting string to define where the day, month and year is. >>> objDate = datetime.strptime(strDate, '%m/%d/%y') >>> objDate datetime.datetime(2018, 2, 4, 0, 0) Now that Python understands this string is an actual date, we can either leave it as-is or convert it back to a string in a different format.
๐ŸŒ
Adverity
docs.adverity.com โ€บ reference โ€บ 2-enrich โ€บ python-expressions-for-managing-dates โ€บ converting-dates-from-one-format-in-to-another.htm
Converting dates from one format to another
Enter the date format to convert using date placeholders. For example, the date 01-03-2022 (1 March 2022) is in the date format %d-%m-%Y. format_to_use - This is the new format for the dates. Enter the new date format using date placeholders. See the examples section below for a worked example.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.to_datetime.html
pandas.to_datetime โ€” pandas 3.0.1 documentation - PyData |
The numeric values would be parsed as number of units (defined by unit) since this reference date. If 'unix' (or POSIX) time; origin is set to 1970-01-01. If 'julian', unit must be 'D', and origin is set to beginning of Julian Calendar. Julian day number 0 is assigned to the day starting at noon on January 1, 4713 BC. If Timestamp convertible (Timestamp, dt.datetime, np.datetimt64 or date string), origin is set to Timestamp identified by origin.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ converting-string-yyyy-mm-dd-into-datetime-in-python
Converting string into DateTime in Python - GeeksforGeeks
July 23, 2025 - ... Explanation: Here, we passed the date string '2023-07-25' to parse(). It automatically recognized the format and returned a full datetime object. datetime.strptime() method, part of Python's datetime module, efficiently converts a date string ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-a-string-to-a-date-in-python
How to convert a string to a date in Python
Python allows you to convert the string type date into a datetime object using strptime() method. The syntax for the method used to convert string to datetime object is strptime(x,y) where: ... y is the format directives in which the string ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ strftime-in-python
strftime() Python โ€“ Datetime Format Tutorial
July 15, 2022 - Let's see some of them: from datetime ... print(string_date) # 2022 ยท datetime.now returns the current date. Using the strftime method and the "%Y" character, the date is converted to a string showing the year....