from random import *
from time import *
date1 = (2005, 1, 1, 0, 0, 0, -1, -1, -1)
time1 = mktime(date1)
date2 = (2006, 1, 1, 0, 0, 0, -1, -1, -1)
time2 = mktime(date2)
random_time = uniform(time1, time2)
print asctime(localtime(random_time))
14.18.time |
| 14.18.1. | time.asctime |
| 14.18.2. | time.time() returns the current system time |
| 14.18.3. | time.localtime(secs) returns the time in the form of (year, month, day, hour, minute, second, day of week, day of year, daylight savings). |
| 14.18.4. | time.ctime(secs) returns the time, specified by secs since the UTC, as a formatted, printable string. |
| 14.18.5. | time.clock() returns the current CPU time as a floating-point number that can be used for various timing functions |
| 14.18.6. | time.sleep(sec) forces the current process to sleep for the number of seconds specified by the floating-point number secs |
| 14.18.7. | Random time |
| 14.18.8. | Creating a New Time |
| 14.18.9. | You can print the time values using the strftime() method. |
| 14.18.10. | Time Operations |
| 14.18.11. | sleep() method of time module example |