| | |
Python automatic date?
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
You should try using the time module
Python Syntax (Toggle Plain Text)
import time print time.localtime()
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
you can use the following code:
that just gives the hour and the minutes
Python Syntax (Toggle Plain Text)
time.localtime()[3:5]
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
you could do it by making it into the amount of minutes. This way you can make sure it stays base 60
TO get the difference in minutes:
to make it back into hours and minutes:
I think that works
TO get the difference in minutes:
Python Syntax (Toggle Plain Text)
g = time.localtime()[3:5] f = time.localtime()[3:5] m = g[0]*60+g[1] n = f[0]*60+f[1] print n-m
Python Syntax (Toggle Plain Text)
g = time.localtime()[3:5] f = time.localtime()[3:5] m = g[0]*60+g[1] n = f[0]*60+f[1] g=n-m hours = g/60 g=g-hours*60 mn = g print hours,":",mn
Last edited by Paul Thompson; Jun 4th, 2008 at 6:45 am. Reason: used keyword as variable
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
no worries
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
![]() |
Similar Threads
- Programming FAQ - Updated 1/March/2005 (Computer Science)
- Searching and Comparing strings from an XML Document (Python)
Other Threads in the Python Forum
- Previous Thread: Total newbie, please help with python classes
- Next Thread: Another problem, subtracting time.
| Thread Tools | Search this Thread |
alarm app beginner cipher cmd cx-freeze data decimals development dictionary directory dynamic error examples feet file float format ftp function generator getvalue gui halp homework http images import input ip itunes java keycontrol leftmouse line linux list lists logging loop maintain maze millimeter module mouse mysqldb number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo verify vigenere web webservice wikipedia windows wxpython xlwt





