from date/time string to seconds since epoch

Peter Kleiweg p.c.j.kleiweg at rug.nl
Wed Jul 6 15:35:45 EDT 2005


wittempj at hotmail.com schreef op de 6e dag van de hooimaand van het jaar 2005:

> You can calculate the offset of where you are like this:
>
> martin at ubuntu:~ $ python
> Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
> [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> py> import time
> py> offset = 0
> py> if time.daylight:
> py.     offset = time.altzone
> py. else:
> py.     offset = time.timezone
> py.
> py> print offset
> -7200
> py>
>
> You can use time.time() to get the UTC time, then add the offset.

The offset is for this moment, not for the date and time of the
string parsed.

-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html




More information about the Python-list mailing list