Ultimately you want to review the datetime documentation and become familiar with the formatting variables, but here are some examples to get you started:

import datetime

print('Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
print('Timestamp: {:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now()))
print('Date now: %s' % datetime.datetime.now())
print('Date today: %s' % datetime.date.today())

today = datetime.date.today()
print("Today's date is {:%b, %d %Y}".format(today))

schedule = '{:%b, %d %Y}'.format(today) + ' - 6 PM to 10 PM Pacific'
schedule2 = '{:%B, %d %Y}'.format(today) + ' - 1 PM to 6 PM Central'
print('Maintenance: %s' % schedule)
print('Maintenance: %s' % schedule2)

The output:

Timestamp: 2014-10-18 21:31:12

Timestamp: 2014-Oct-18 21:31:12

Date now: 2014-10-18 21:31:12.318340

Date today: 2014-10-18

Today's date is Oct, 18 2014

Maintenance: Oct, 18 2014 - 6 PM to 10 PM Pacific

Maintenance: October, 18 2014 - 1 PM to 6 PM Central

Reference link: https://docs.python.org/3.4/library/datetime.html#strftime-strptime-behavior

Answer from Zach Reneau on Stack Overflow
🌐
PYnative
pynative.com › home › python › python datetime › timestamp in python
Python Timestamp With Examples – PYnative
December 5, 2021 - from datetime import datetime # Timezone Name. date_String = "23/Feb/2012:09:15:26 UTC +0900" dt_format = datetime.strptime(date_String, '%d/%b/%Y:%H:%M:%S %Z %z') print("Date with Timezone Name::", dt_format) # Timestamp timestamp = ...
🌐
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing a specific timestamp in UTC is by calling datetime.fromtimestamp(timestamp, tz=timezone.utc).
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Timestamp.html
pandas.Timestamp — pandas 3.0.2 documentation
They can be passed by position ... but not both mixed together. ... >>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific') Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific')...
🌐
Flexiple
flexiple.com › python › python-timestamp
Python Timestamp - Get Current timestamp in Python - Flexiple
In this example, the fromtimestamp() function converts the given timestamp to a datetime object, representing the date and time associated with that timestamp. Additionally, Python offers flexibility in formatting datetime objects into human-readable strings using the strftime() method.
🌐
Programiz
programiz.com › python-programming › datetime › timestamp-datetime
Python timestamp to datetime and vice-versa (With Examples)
December 25, 2018 - 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 = datetime.fromtimestamp(timestamp) # print the datetime object and its type print("dt_object =", dt_object) ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › get-current-timestamp-using-python
Get Current Timestamp Using Python - GeeksforGeeks
May 5, 2025 - The datetime module provides the now() function to get the current date and time, and the timestamp() method converts it to a timestamp.
🌐
Codedamn
codedamn.com › news › python
Working with Timestamps in Python
July 3, 2023 - from datetime import datetime current_timestamp = datetime.now() formatted_timestamp = current_timestamp.strftime('%Y-%m-%d %H:%M:%S') print(formatted_timestamp) In this example, '%Y-%m-%d %H:%M:%S' is the format string.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › datetime
Python datetime (With Examples)
Python datetime.date Class · Example 3: Date object to represent a date · Example 5: Get the date from a timestamp · Example 6: Print today's year, month and day · Python datetime.time Class · Example 7: Time object to represent time · Example 8: Print hour, minute, second and microsecond ·
🌐
The New Stack
thenewstack.io › home › python: introduction to timestamps and time strings
Python: Introduction to Timestamps and Time Strings - The New Stack
July 27, 2025 - Let’s say you want your output to include the Month, Day, Year, Hour, and Minutes (which would be %m-%d-%Y %H:%M). The Python code for this would look like: from datetime import datetime timestamp = datetime.now() formatted_string = ...
🌐
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
import time ts = time.gmtime() print(time.strftime("%Y-%m-%d %H:%M:%S", ts)) # 2026-03-19 07:35:27 print(time.strftime("%x %X", ts)) # 03/19/26 07:35:27 # Iso Format print(time.strftime("%c", ts)) # Thu Mar 19 07:35:27 2026 # Unix timestamp print(time.strftime("%s", ts)) # 1773902127
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.23.4 › generated › pandas.Timestamp.html
pandas.Timestamp — pandas 0.23.4 documentation
This converts a datetime-like string >>> pd.Timestamp(‘2017-01-01T12’) Timestamp(‘2017-01-01 12:00:00’)
🌐
Timestamp Converter
timestamp.online › article › how-to-get-current-timestamp-in-python
How To Get Current Timestamp In Python - Code Example
If you want to get timestamp in Python, you may use functions from modules time, datetime, or calendar.
🌐
Learn By Example
learnbyexample.org › working-with-timestamps-in-python
Working with Timestamps in Python - Learn By Example
April 23, 2024 - So it’s important to understand the difference between naive and timezone-aware datetime objects when working with timestamps, especially if your application deals with dates and times across multiple timezones. Incorrect handling of timezones can result in errors in how time is interpreted and compared. Let’s illustrate this with an example. The code below demonstrates how Python handles timestamps for both naive and timezone-aware datetime objects.
🌐
Learn By Example
learnbyexample.org › python-datetime-timestamp-method
Python datetime timestamp() Method - Learn By Example
April 15, 2024 - So it’s important to understand the difference between naive and timezone-aware datetime objects when working with timestamps, especially if your application deals with dates and times across multiple timezones. Incorrect handling of timezones can result in errors in how time is interpreted and compared. Let’s illustrate this with an example. The code below demonstrates how Python handles timestamps for both naive and timezone-aware datetime objects.
🌐
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 - Previously, we touched on converting timestamps to datetimes using the fromtimestamp() function. While this function provides the date and time in your system’s local time zone by default, you might need to consider different time zones when working with data from diverse sources. Python’s datetime module allows you to work with time zones using the pytz library. Here’s a quick example of converting a timestamp to a datetime with a specific time zone:
🌐
Dataquest
dataquest.io › blog › python-datetime-tutorial
Python Datetime Tutorial: Manipulate Times, Dates, and Time Spans
January 5, 2026 - Similarly, we can do the reverse conversion using fromtimestamp(). This is a datetime function that takes a timestamp (in float format) as an argument and returns a datetime object, as below:
🌐
TutorialsPoint
tutorialspoint.com › python_pandas › python_pandas_timestamp.htm
Python Pandas - Timestamp
The to_datetime() function creates timestamp from various formats like strings, lists of dates, or integers. The following example creates a Timestamp from a list of strings using the pd.to_datetime() function.
🌐
Real Python
realpython.com › python-get-current-time
How to Get and Use the Current Time in Python – Real Python
September 25, 2023 - There’s a slight deviation from the ISO 8601 standard in the format that Python uses, though. The standard says that the date and the hour parts of the timestamp should be separated by a T character, but the default datetime object passed through the print() function separates them with a single space.