Web Analytics

Python datetime.now() Method

Date & Time Current Time

The datetime.now() method returns the current local date and time.

It is part of the datetime module.

Syntax

datetime.datetime.now(tz)

Parameters

Parameter Description
tz Optional. The timezone to display the time in. If not specified, the local time is returned.

Return Value

A datetime object containing the current date and time.

Example

Using the now() method:

Output
Click Run to execute your code

Related Functions