In message <[EMAIL PROTECTED]>, Keith Hughitt wrote: > I have a UTC date (e.g. 2008-07-11 00:00:00). I would like to create a > UTC date ...
>>> import calendar >>> calendar.timegm((2008, 7, 11, 0, 0, 0, 0, 0, -1)) 1215734400 [EMAIL PROTECTED]> TZ=NZ date -d "00:00:00 01-Jan-1970Z +1215734400 seconds" Fri Jul 11 12:00:00 NZST 2008 The general form of the call is "calendar.timegm((Y, M, D, hh, mm, ss, 0, 0, -1))". See also <http://docs.python.org/lib/module-time.html>, <http://docs.python.org/lib/module-calendar.html>. > ... so that when I send it to MySQL (which treats all dates at local dates > by default) ... I don't like to use MySQL's date/time types. Instead, I usually have a simple integer field containing seconds since some origin time in UTC. If the time is that of some event, an origin of 00:00:00 01-Jan-1970 lets you use Unix/Linux system times directly. For recording dates/times that might go further back (e.g. dates of birth, historical events), I have used the Julian day origin, 1st January 4713 BC. -- http://mail.python.org/mailman/listinfo/python-list