timestr.ing

Paste in any timestamp and a strptime-compatible format string to get started

Python

Python code examples to convert using the datetime module

from datetime import datetime


def convert_timestamp(timestamp: str, input_format: str, output_format: str) -> str:
    datetime_obj = datetime.strptime(timestamp, input_format)
    return datetime_obj.strftime(output_format)


input_timestamp = "undefined"
strftime_format = "undefined"
strptime_format = "undefined"

converted_time = convert_timestamp(input_timestamp, strftime_format, strptime_format)

print(converted_time)

Reference table

The supported directives for the formatter and parser are listed below
DirectiveDescription
%aabbreviated weekday name
%Afull weekday name
%babbreviated month name
%Bfull month name
%cthe locale's date and time, such as %x, %X
%dzero-padded day of the month as a decimal number [01,31]
%espace-padded day of the month as a decimal number [ 1,31]; equivalent to %_d
%fmicroseconds as a decimal number [000000, 999999]
%gISO 8601 week-based year without century as a decimal number [00,99]
%GISO 8601 week-based year with century as a decimal number
%Hhour (24-hour clock) as a decimal number [00,23]
%Ihour (12-hour clock) as a decimal number [01,12]
%jday of the year as a decimal number [001,366]
%mmonth as a decimal number [01,12]
%Mminute as a decimal number [00,59]
%Lmilliseconds as a decimal number [000, 999]
%peither AM or PM
%qquarter of the year as a decimal number [1,4]
%Qmilliseconds since UNIX epoch
%sseconds since UNIX epoch
%Ssecond as a decimal number [00,61]
%uMonday-based (ISO 8601) weekday as a decimal number [1,7]
%USunday-based week of the year as a decimal number [00,53]
%VISO 8601 week of the year as a decimal number [01, 53]
%wSunday-based weekday as a decimal number [0,6]
%WMonday-based week of the year as a decimal number [00,53]
%xthe locale's date, such as %-m/%-d/%Y
%Xthe locale's time, such as %-I:%M:%S %p
%yyear without century as a decimal number [00,99]
%Yyear with century as a decimal number, such as 1999
%Ztime zone offset, such as -0700, -07:00, -07, or Z
%%a literal percent sign (%)

Made with ❤️ in Los Angeles