How to get current time in Python

0 votes
What method is used to get the cuurent time as output?
Jun 22, 2019 in Python by Shabnam
• 930 points
520 views

1 answer to this question.

0 votes

Hi,

You can use Datetime class.

Input:

import datetime
datetime.datetime.now()

Output:

datetime.datetime(2019, 6, 21, 13, 55, 50, 438476)

Input:

print(datetime.datetime.now())

Output:

2019-06-21 13:56:25.974482

And now for just time:

Input:

datetime.datetime.now().time()

Output:

datetime.time(14, 2, 0, 844387)

Input:

print(datetime.datetime.now().time())

Output:

14:02:15.714107







answered Jun 22, 2019 by Taj
• 1,080 points

Related Questions In Python

0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8, 2019 in Python by rajesh
• 1,270 points
1,698 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,830 points
521 views
0 votes
1 answer

How to get the current time in Python?

Use: >>> import datetime >>> datetime.datetime.now() datetime.datetime(2009, 1, 6, 15, ...READ MORE

answered Nov 20, 2020 in Python by Gitika
• 65,910 points
436 views
0 votes
2 answers

how to print the current time using python?

print(datetime.datetime.today()) READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
688 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,056 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,476 views
0 votes
1 answer

How to put time delay in Python?

You can use sleep() method to sleep ...READ MORE

answered May 28, 2019 in Python by Taj
• 1,080 points
476 views
+1 vote
1 answer

How can I reverse list in Python?

Reversing a list is a commonly used ...READ MORE

answered May 13, 2019 in Python by Taj
• 1,080 points
689 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP