Datetime

Datetime

Python also includes the Datetime library to help when you need to access and manipulate date or time information. To import is use:

import Datetime

Function Description
datetime.now() Gives the time as a datetime object in yyyy-mm-dd hh:mm:ss.ssssss
datetime.now().date() Gives the date in yyyy-mm-dd
datetime.now().time() Gives the time in hh:mm:ss.ssssss
variable.year Gives the year as an integer if the variable is a datetime or date object YYYY
variable.strftime("%A") Gives the full weekday name of a datetime or date object
dateutil.parser.parse("…") The dateutil module's parser can parse a string into a datetime object (e.g., parse("June 23, 2025")).

To use the dateutil parser, install it via

pip install python-dateutil 

You can then use it like:

from dateutil import parser
parser.parse("June 23, 2025")