UTC equivalent of time.mktime() ?
Donn Cave
donn at u.washington.edu
Wed Apr 17 13:51:58 EDT 2002
Quoth Graham Ashton <gashton at cmedltd.com>:
| On Wed, 2002-04-17 at 17:11, Mark McEahern wrote:
|> Why not just use the mxDateTime library and just do something like this:
|>
|> mx.DateTime.utc().ticks()
|
| I appreciate that I could (and thanks for the suggestion), but does this
| really mean that via the standard library there is no easy way to
| convert "1 Jan 1970" to 0 (i.e. string to seconds since epoch)?
I have not been following, so pardon me if this has already been
suggested, but on a platform where you have 2.0 or later and strptime,
this might do that:
lt = time.mktime(time.strptime(sys.argv[1], '%d %b %Y'))
utoffset = time.mktime(time.gmtime(lt)) - lt
print lt - utoffset
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list