Epoch


Get Epoch time, time in python and Django
Epoch Wiki   In simple words Epoch Time is number of ticks since 1970.

How to get current epoch time ?

time.time()  -->  1353060315.441321
int(time.time()) -->  1353060315

now = datetime.datetime.now()
time.mktime(now.timetuple())  --> 1353060315


My Notes:

time.gmtime()
time.struct_time(tm_year=2012, tm_mon=11, tm_mday=16, tm_hour=10, tm_min=6, tm_sec=44, tm_wday=4, tm_yday=321, tm_isdst=0)

datetime.datetime.now()
datetime.datetime(2012, 11, 16, 15, 34, 35, 433184)


In Django Application

mysql time field's should be  DATETIME
Eg.        allocate_time     | datetime      | YES  |     | NULL    |    

In models.py  field type should be models.DateTimeField()