Python and datetime

Links

Here are some links

Examples

An example of using datetime is

import time
import datetime
now=datetime.datetime.now() 

#now.tzinfo = 'GMT'; # fails, now.tzinfo is immutable

print now.ctime() print now.isoformat() print now.tzinfo

but otherwise produces the following output

Fri Jan  2 15:15:07 2009
2009-01-02T15:15:07.896000
None

I performed these tests on a windows XP box. tzinfo is empty is this a windows/configuration thing? I can test this with UNIX. I tried setting the TZ variable before running the program and it makes no difference. I found one reference that says Python datetime doesn’t do TimeZones.

Obviously, using the from statement would change the call syntax

from datetime import datetime
now=datetime.now()

should work

Related Posts

  • Converting dates to strings using Python While working on converting ello.json to rss, I needed to convert the date formats, I […]
  • Python I returned to Python in Oct 2010. I have two problems to solve, converting my […]
  • Unicode in Python It's a very long time since I have had to deal with binary code translations, but when […]
  • Shell Programming This page never seems to age, it just contains some idioms I like to use in my .login […]
  • Socket Programming It has to be Python Don't ask. http://docs.python.org/howto/sockets.html, the […]

Leave a Reply

Your email address will not be published. Required fields are marked *