How to get current time in Python

0 votes
What method is used to get the cuurent time as output?
Jun 21, 2019 in Python by Shabnam
• 930 points
130 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 21, 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,230 points
512 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,810 points
177 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,870 points
63 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
191 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,976 views
0 votes
0 answers
+4 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,810 points
1,511 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
126 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
165 views