Good morning everyone, I was taking the date and time lessons and all we did had to do with hours/minutes/seconds but what if we need a precise time of milliseconds or even more precise. How do I do that?
have you looked at the documentation:
datetime.now() even gives microseconds
So if I would print now.microsecond how big of a number would I get? The number of seconds converted into microseconds or only the decimals corresponding to the microseconds?
Well, if you read the documentation (or at least the portion you need) and then implemented this, you could see for yourself and would teach you far more then me just telling you the answer
The less i help, the better it actually is (although this might seems to contradict each other, its not)
First of, thank you for your time. The part that I was having doubts about was this one:
"A millisecond is converted to 1000 microseconds.
A minute is converted to 60 seconds.
An hour is converted to 3600 seconds.
A week is converted to 7 days."
But nevermind I figured it out. I also noticed that there was no millisecond attribute, will I learn a way to convert or transform the results (aka. shortening the microseconds result to match the number of milliseconds)?
I also tried to “from datetime import datetime” then print it, and do the same thing ahead on the code. Is it safe to say that the time that it took to run the code between the first “from datetime import datetime” and the second one is the difference between the printed times?
Sorry for bothering you. Thanks in advance.
careful, you are reading here about timedelta, delta indicates differences between two times. Is this really what you want to use? So far i gathered you just want to use
class datetime.datetime, which offers:
A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo.
look at datetime objects:
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.