cs_lang:python:things-to-know:date-and-time
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
cs_lang:python:things-to-know:date-and-time [2011/06/17 07:53] – cedric | cs_lang:python:things-to-know:date-and-time [2012/06/20 11:14] (current) – cedric | ||
---|---|---|---|
Line 8: | Line 8: | ||
epoch = int(time.mktime(time.strptime(date_time, | epoch = int(time.mktime(time.strptime(date_time, | ||
print epoch | print epoch | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | def delta_time(dt, | ||
+ | """ | ||
+ | Adds a time delta to a datetime object with a specific format. | ||
+ | |||
+ | Example of call: | ||
+ | >>> | ||
+ | >>> | ||
+ | 12:50:54 | ||
+ | """ | ||
+ | return datetime.datetime(*time.strptime(dt, | ||
</ | </ |
cs_lang/python/things-to-know/date-and-time.txt · Last modified: 2012/06/20 11:14 by cedric