cs_lang:python:things-to-know:date-and-time
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
cs_lang:python:things-to-know:date-and-time [2011/06/17 07:53] – created cedric | cs_lang:python:things-to-know:date-and-time [2012/06/20 11:14] (current) – cedric | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | <code python> |
import time | import time | ||
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> |
+ | |||
+ | < | ||
+ | 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, | ||
+ | </code> |
cs_lang/python/things-to-know/date-and-time.txt · Last modified: 2012/06/20 11:14 by cedric