Get Current time | Python

The is a class method that returns the current time.
>>> import datetime >>> print( 12:15:45.245136
This method uses the time.localtime without the timezone info.
>>> import datetime >>> print( 2021-08-25 12:16:02.613020

Get current time - python3

how to get current time in python

**datetime.utcnow() is a non-timezone aware object.

Python time interval measurement

The Python time() function returns the number of seconds passed since epoch.
>>> from time import time >>> milliseconds = time() >>> print(milliseconds) 1629874049.2520282
milliseconds - float number, good for time interval measurement. For the standard CPython implementation on most platforms this will return a UTC value.

Isoformat() of Time Class In Python

The method isoformat() returns the time as a string in the format as specified by the ISO 8601 standard. The return value can contain a string of minimum length 2, representing HH for hours and of maximum length 15, representing HH:MM:SS:ssssss.
>>> import datetime >>> '2021-08-25T12:18:08.371450'

Get current time using Python pandas

>>> import pandas as pd >>> print( 2021-08-25 12:18:38.629239

Get current time using numpy

>>> import numpy as np >>> str(np.datetime64('now')) '2021-08-25T06:48:56'