Python date and time snippets

Documentation

Import directives

In [1]:
import datetime

Get current date and time

In [2]:
datetime.datetime.now()
Out[2]:
datetime.datetime(2017, 7, 6, 15, 26, 26, 166135)
In [3]:
print(datetime.datetime.now())
2017-07-06 15:26:26.181670