>>> import time
>>> import datetime
>>> s = "01/12/2011"
>>> time.mktime(datetime.datetime.strptime(s, "%d/%m/%Y").timetuple())
1322697600.0
Answer from Katriel on Stack Overflow
People also ask

How do I convert a Python timestamp to a datetime?
You can use datetime.fromtimestamp() to convert a UNIX timestamp to a readable datetime. Just pass the timestamp to it, and it gives you the date and time.
🌐
wscubetech.com
wscubetech.com › resources › python › timestamp-datetime
Python Timestamp to Datetime and Vice-Versa: With Examples
Can I convert a timestamp directly to a specific datetime format in Python?
Yes. First, convert the timestamp to a datetime, then use .strftime() to format it however you like (e.g., "YYYY-MM-DD" or "HH:MM").
🌐
wscubetech.com
wscubetech.com › resources › python › timestamp-datetime
Python Timestamp to Datetime and Vice-Versa: With Examples
What is a timestamp in Python?
A timestamp in Python is a number that represents seconds since January 1, 1970 (UTC). It’s often used for storing or calculating date and time.
🌐
wscubetech.com
wscubetech.com › resources › python › timestamp-datetime
Python Timestamp to Datetime and Vice-Versa: With Examples
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-date-string-to-timestamp-in-python
Convert Date String to Timestamp in Python - GeeksforGeeks
October 29, 2025 - datetime.timestamp() converts a datetime object to a Unix timestamp in seconds and returns a float. It assumes local time if no timezone is set. ... from datetime import datetime s = "20/01/2020" dt = datetime.strptime(s, "%d/%m/%Y") res = ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-timestamp-string-to-datetime-object-in-python
How to convert timestamp string to datetime object in Python? - GeeksforGeeks
August 23, 2025 - Explanation: s is parsed automatically ... ISO 8601 format (i.e., "YYYY-MM-DD HH:MM:SS"), fromisoformat() is the cleanest and most efficient method to convert it to a datetime object....
🌐
Programiz
programiz.com › python-programming › datetime › timestamp-datetime
Python timestamp to datetime and vice-versa (With Examples)
December 25, 2018 - We can simply use the fromtimestamp() method from the datetime module to get a date from a UNIX timestamp. from datetime import datetime # timestamp is number of seconds since 1970-01-01 timestamp = 1545730073 # convert the timestamp to a datetime object in the local timezone dt_object = ...
🌐
InfluxData
influxdata.com › home › how to convert timestamp to datetime in python | influxdata
How to Convert Timestamp to DateTime in Python | InfluxData
June 28, 2023 - Converting a timestamp to a datetime object is a common task when dealing with time-related data. Python’s datetime module comes to the rescue with the fromtimestamp() function, which allows us to easily perform this conversion.
🌐
The New Stack
thenewstack.io › home › convert timestamps to strings like a python pro
Convert Timestamps To Strings Like a Python Pro - The New Stack
July 14, 2025 - Converting timestamps to readable dates is easy with Python. Using the datetime module, you can quickly convert a timestamp to a date string Python developers trust.
Find elsewhere
🌐
w3resource
w3resource.com › python-exercises › date-time-exercise › python-date-time-exercise-6.php
Python: Convert unix timestamp string to readable date - w3resource
July 22, 2025 - After converting the timestamp into a datetime object, it formats the datetime object into a string representation using the "strftime()" method with the specified format '%Y-%m-%d %H:%M:%S'. This format represents the datetime as "Year-Month-Day ...
🌐
Timestamp Converter
timestamp.online › article › how-to-convert-timestamp-to-datetime-in-python
How To Convert Timestamp To Date and Time in Python - Code Example
Convert timestamp to date or date to timestamp easily · There are multiple ways how you can convert timestamp to human readable form in Python.
🌐
WsCube Tech
wscubetech.com › resources › python › timestamp-datetime
Python Timestamp to Datetime and Vice-Versa: With Examples
October 1, 2025 - Convert Python timestamp to datetime and vice-versa easily with built-in functions. Learn how to manage date and time conversions in Python effectively.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Timestamp.strftime.html
pandas.Timestamp.strftime — pandas 3.0.1 documentation
Format string to convert Timestamp to string. See strftime documentation for more information on the format string: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior. See also · Timestamp.isoformat · Return the time formatted according to ISO 8601.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_datetime.html
pandas.to_datetime — pandas 3.0.1 documentation - PyData |
If Timestamp convertible (Timestamp, dt.datetime, np.datetimt64 or date string), origin is set to Timestamp identified by origin.
🌐
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
Return the local date and time corresponding to the POSIX timestamp, such as is returned by time.time(). If optional argument tz is None or not specified, the timestamp is converted to the platform’s local date and time, and the returned datetime object is naive.
🌐
Medium
medium.com › @whyamit404 › converting-pandas-timestamp-to-datetime-0390728d0a2c
Converting Pandas Timestamp to Datetime | by whyamit404 | Medium
February 26, 2025 - This distinction matters when you’re working with Python libraries that expect datetime rather than Pandas’ version. ... You might be wondering, “Isn’t there a simpler way?” Yep, there is. ... This method is flexible because it doesn’t just work with single timestamps. It shines when you’re working with an entire DataFrame. Let’s see that in action: # Converting a column in a DataFrame df = pd.DataFrame({'timestamp': [pd.Timestamp('2024-01-01'), pd.Timestamp('2024-02-01')]}) df['datetime'] = pd.to_datetime(df['timestamp']) print(df)
🌐
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 - In this article, you’ll use strptime() to convert strings into datetime and struct_time() objects. Deploy your Python applications from GitHub using DigitalOcean App Platform.
🌐
Codedamn
codedamn.com › news › python
Working with Timestamps in Python
July 3, 2023 - It is the number of seconds that ... date). We can convert a Unix timestamp to a datetime object in Python using the fromtimestamp() function....
🌐
The New Stack
thenewstack.io › home › how to convert a timestamp to a string in python
How To Convert a Timestamp to a String in Python - The New Stack
November 21, 2024 - This tutorial shows how to convert Python timestamps into readable date strings using the pandas and datetime Python libraries.