time now() python code example

Example 1: python print time

import datetime
now = datetime.datetime.now()
print (now.strftime("%Y-%m-%d %H:%M:%S"))
# key: https://strftime.org/

Example 2: find todays date in python

from datetime import datetime

# Current date time in local system
print(datetime.now())
print(datetime.date(datetime.now())) ##For Date

Example 3: python now

now_time = datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")
print(now_time)

Example 4: python datetime now

import datetime
print(datetime.datetime.now()) #datetime.datetime.now() is the syntax

Example 5: use datetime python to get runtime

from datetime import datetime

start = datetime.now()
# code ...
print(datetime.now()-start)