Answers for "how to import datetime in python"

11

get the current year in python

import datetime
now = datetime.datetime.now().year
print(now)
Posted by: Guest on May-12-2020
2

import datetime

from datetime import datetime

date = datetime.now()
print(date)
# Prints in the format year, month, day, hour, minute, second, and microsecond
Posted by: Guest on February-15-2021
26

datetime python

from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
Posted by: Guest on December-09-2020
0

how to import date and time in python

pip install datetime
Posted by: Guest on June-24-2021

Code answers related to "how to import datetime in python"

Python Answers by Framework

Browse Popular Code Answers by Language