usage on the time module(newbie)

John Nielsen nielsenjf at my-deja.com
Thu Jan 18 09:08:25 EST 2001


It depends on what OS you are using. I don't think windows supports
strptime.

However, there are other options.

Since you're new, let's go through the time functions:

time.time() -- gives you seconds :
	979824998.188
time.localtime(time.time()) -- gives you a tuple from seconds:
	(2001, 1, 18, 8, 35, 20, 3, 18, 0)

time.strftime('%d %H %M %S %Y',(2001, 1, 18, 8, 35, 20, 3, 18, 0)) --
	takes the tuple and gives you a date: '18 08 35 20 2001'

time.mktime(2001, 1, 18, 8, 35, 20, 3, 18, 0) -- takes the tuple
and gives you seconds: 979824920.0

What you basically need to do, is convert you date string to a tuple
and then use mktime, to get seconds.

The tuple would be of the format:
(yr,mnth,day,hr,min,sec,weekday,julian,dayling savings)



Hope this helps,


john






In article <945neg$72d$1 at nnrp1.deja.com>,
  fimafeng at my-deja.com wrote:
> Hello:
>
> I'm having difficulty with the syntax for the function strptime
> in the time module
>
> For instance. If I have a variable....
> fred='Mon Jan 15 00:30:24 2001'
>
> what syntax would I use to parse this into a tuple?
> I have tried
> time.strptime(Mon Jan 15 00:30:24 2001[])
> but I receive an error..
>
> I did not see any examples in the documentation.
>
> Any help is greatly appreciated...
> Thanks,
> Chris
> fimafeng at yahoo.com
>
> Sent via Deja.com
> http://www.deja.com/
>

--
nielsenjf at my-Deja.com


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list