import timeand we can get started:
With the time module you can simply use
time.time() to return the current time in seconds since the Unix epoch (1970-01-01T00:00:00Z). Example:
To get the local time, use
time.localtime(). This will return a time-tuple. Which can be made readable with a simple additional line:
time.asctime(). As a result, you get the example down below:
It’s actually the localtime of the server it is running on in the example above. You could also pass time in seconds (since the Unix epoch) and turn it to local time with this function.
The time module can do more of course. It also can put your process to sleep :P. Use
time.sleep(4). This will pause your sequence for 4 seconds.
You can learn python with several books. Here’s a couple of them down below: