0 votes
1 view
in Python by (47.8k points)

I would like to get the current time in Python and assign them into variables like year, month, day, hour, minute. How can this be done in Python 2.7?

1 Answer

0 votes
by (107k points)

To get the current time in Python and break up into year, month, day, hour, minute the datetime module is your friend:

import datetime 

now = datetime.datetime.now() 

print(now.year, now.month, now.day, now.hour, now.minute, now.second) 

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...