Converting a string to time - simple task but don't know how to do it!

Mark McEahern marklists at mceahern.com
Sat Sep 14 21:34:22 CEST 2002


Try:

  import time
  s = "<<your time string>>"
  t = time.strptime(s)

I think strptime is only supported on Unix?

So if you get an AttributeError when you try that, your best best is to use
the mx.DateTime package (a google search should find that).

mx.DateTime works like this:

  import mx.DateTime
  d = mx.DateTime.DateTimeFrom(your_time_string)
  d2 = mx.DateTime.now()
  diff = d2 - d1
  print diff

// m

-





More information about the Python-list mailing list