[Tutor] Date and Time questions
Rob Andrews
rob@jam.rr.com
Mon, 9 Jul 2001 10:00:53 -0500
# -----Original Message-----
# From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
# Schmidt, Allen J.
# Sent: Monday, July 09, 2001 9:23 AM
# To: tutor@python.org
# Subject: [Tutor] Date and Time questions
#
#
# I have looked around for things that deal with Date and Time.
# All I want to do is be able to assign a date/time value to a
# variable. Like
# 20010709_18:05.
# Does not need to be a date object just a text string that I can
# use to drop
# into a database table or use in other ways.
#
# The date time stuff seems a bit overly complicated. Any tips or
# pointers to
# online resources I may have missed.
#
Here are a few things you can do with the time module:
# first import the time module
>>> import time
# the time module allows a few different ways to express time
>>> time.time()
994689648.35000002
>>> time.clock()
6.7047721215575185e-006
# assigning the value to a variable is pretty painless
>>> currenttime=time.time()
>>> currenttime
994689713.05999994
# Personally, I like to be able to make some sense of it when I look at it.
>>> time.ctime(currenttime)
'Mon Jul 09 09:41:53 2001'
>>> time.ctime(time.time())
'Mon Jul 09 09:45:23 2001'
Hope this helps,
Rob
"Perl is worse than Python because people wanted it worse." Larry Wall
(Creator of Perl), 14 Oct 1998
Useless Python: http://www.lowerstandard.com/python/