+ 3

how do you use datetime module?

Can someone explain simply how to use the datetime module?

14th Jul 2017, 2:54 AM
Yoni S
Yoni S - avatar
3 Answers
+ 8
# Import the module import datetime # Initialize a variable now = datetime.now() # Print h/m/s print(now.hour, now.minute, now.second)
14th Jul 2017, 3:17 AM
MrCoder
MrCoder - avatar
+ 8
@Yoni S Theres something wrong in the above code, heres the correct one :) import datetime now = datetime.datetime.now() print(now.hour, now.minute, now.second)
14th Jul 2017, 11:44 AM
MrCoder
MrCoder - avatar
+ 2
@mrcoder thank you!
14th Jul 2017, 3:26 AM
Yoni S
Yoni S - avatar