| | |
File with date + time
![]() |
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
I just was messing around with the time module tonight. are you asking for something simple like
Python Syntax (Toggle Plain Text)
>>> import time >>> time.ctime() 'Mon Oct 24 23:30:47 2005'
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
how about this
edit added later//
I noticed a time like one minute after 12 looks like this
that could be fixed with a little more code
Python Syntax (Toggle Plain Text)
import time # time.localtime() splits the time into elements of a tuple tuple_time = time.localtime() # don't europeans do day/month/year ? time_stamp = "%s:%s %s/%s/%s" %(tuple_time[3], tuple_time[4], tuple_time[2], tuple_time[1], tuple_time[0]) print time_stamp
edit added later//
I noticed a time like one minute after 12 looks like this
Python Syntax (Toggle Plain Text)
0:1 25/10/2005
that could be fixed with a little more code
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
this code fixes that issue
Python Syntax (Toggle Plain Text)
def time_stamp(): import time tuple_time = time.localtime() hours = tuple_time[3] if int(hours) in range(10): hours = "0%s" %hours minutes = tuple_time[4] if int(minutes) in range(10): minutes = "0%s" %minutes day = tuple_time[2] month = tuple_time[1] year = tuple_time[0] # don't europeans do day/month/year ? time_ = "%s:%s %s/%s/%s" %(hours, minutes, day, month, year) return time_
In a perfect world exceptions would not be needed.
That looks good. Many countries in Europe have day/month/year format, but that doesn't make much sense for what I may want to do. I am thinking about a date and time stamp starting each data line where the line could be sorted. It could have to look something like year/month/day hour:minute:second to do this rightly.
The tuple_time almost has this sorting format.
The tuple_time almost has this sorting format.
![]() |
Similar Threads
- date and time in file name (VB.NET)
- How to compare the last two modified date and time of a file (C)
- How to Get Last Accessed/Created/Modified File Date and Time (C)
Other Threads in the Python Forum
- Previous Thread: wxPython slider help
- Next Thread: Doubling the size of an image
| Thread Tools | Search this Thread |
accessdenied apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionary dynamic edit enter examples file float format function gui homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysql mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl pysimplewizard python random recursion redirect remote reverse scrolledtext session simple smtp software sprite statictext string strings syntax table tennis terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






