Web Analytics

Python datetime.strptime() Method

Date & Time โ€ข Parse Date

The strptime() method creates a datetime object from the given string based on a format string.

It is the reverse of strftime().

Syntax

datetime.strptime(string, format)

Parameters

Parameter Description
string Required. The string to parse.
format Required. The format of the string (see strftime for codes).

Return Value

A datetime object.

Example

Using the strptime() method:

Output
Click Run to execute your code

Related Functions