from IPython.display import HTML
HTML('<iframe src=http://randomibis.com/coolclock/justclock.html width=340 height=340></iframe>')
HTML('<iframe src=http://www.uize.com/examples/digital-clock.html width=850 height=600></iframe>')
In computer world, time starts at 12:00am, January 1, 1970 (epoch). Every time interval is a tick or second.
Question: how many ticks are there since epoch?
import time
nticks = time.time()
print "It is now %f ticks (seconds) past epoch" % nticks
| Index | Attribute | Meaning | Value | Range |
|---|---|---|---|---|
| 0 | tm_year | 4-digit year | 2012 | 1 - 9999 |
| 1 | tm_mon | montd | 11 | 1 - 12 |
| 2 | tm_mday | day of montd | 23 | 1 - 31 |
| 3 | tm_hour | 24 hour | 18 | 0 - 23 |
| 4 | tm_min | minute | 52 | 0 - 59 |
| 5 | tm_sec | second | 6 | 0 - 61 (60 or 61 are leap seconds) |
| 6 | tm_wday | day of week | 4 | 0 - 6 (0 for Monday) |
| 7 | tm_yday | day of year | 328 | 1 - 366 (Julian day) |
| 8 | tm_isdst | daylight savings | 0 | -1, 0, 1 (-1 means library determines DST) |
print "Year (Min, Max): (%d, %d)" % (datetime.MINYEAR, datetime.MAXYEAR)
localtime = time.localtime(time.time())
print "local time is:\n\t", localtime
print "local time is:\n\t", time.asctime(localtime)
import datetime
# what timezone are you in
print time.tzname
import calendar
# set Sunday as 1st column
calendar.setfirstweekday(6)
# show calendar for a month
cal = calendar.month(2012,11)
print cal
# show calendar for a year
cal2 = calendar.calendar(2012)
print cal2
![]() |
![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
from IPython.display import YouTubeVideo
YouTubeVideo('MTx6ha6fRwo')
watch the rest: Time - a BBC documentary